/* File: defines.h */

/* Purpose: global constants and macro definitions */

/*
 * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke
 *
 * This software may be copied and distributed for educational, research, and
 * not for profit purposes provided that this copyright and statement are
 * included in all such copies.
 *
 *
 * James E. Wilson and Robert A. Koeneke released all changes to the Angband code under the terms of the GNU General Public License (version 2),
 * as well as under the traditional Angband license. It may be redistributed under the terms of the GPL (version 2 or any later version), 
 * or under the terms of the traditional Angband license. 
 *
 * All changes in Hellband are Copyright (c) 2005-2007 Konijn
 * I Konijn  release all changes to the Angband code under the terms of the GNU General Public License (version 2),
 * as well as under the traditional Angband license. It may be redistributed under the terms of the GPL (version 2), 
 * or under the terms of the traditional Angband license. 
 */ 

/*
* Do not edit this file unless you know *exactly* what you are doing.
*
* Some of the values in this file were chosen to preserve game balance,
* while others are hard-coded based on the format of old save-files, the
* definition of arrays in various places, mathematical properties, fast
* computation, storage limits, or the format of external text files.
*
* Changing some of these values will induce crashes or memory errors or
* savefile mis-reads.  Most of the comments in this file are meant as
* reminders, not complete descriptions, and even a complete knowledge
* of the source may not be sufficient to fully understand the effects
* of changing certain definitions.
*
* Lastly, note that the code does not always use the symbolic constants
* below, and sometimes uses various hard-coded values that may not even
* be defined in this file, but which may be related to definitions here.
* This is of course bad programming practice, but nobody is perfect...
*
* For example, there are MANY things that depend on the screen being
* 80x24, with the top line used for messages, the bottom line being
* used for status, and exactly 22 lines used to show the dungeon.
* Just because your screen can hold 46 lines does not mean that the
* game will work if you try to use 44 lines to show the dungeon.
*
* You have been warned or a victim of tldr;
*/


/*
* Current version number of Hellband: 0.8.7
*/
#define VERSION_NAME	"Hellband087"
#define VERSION     	"0.8.7"

/* <<VERSION STAMP>> */
#define VERSION_MAJOR   0
#define VERSION_MINOR   8
#define VERSION_PATCH   7

/*
* This value is not currently used
*/
#define VERSION_EXTRA   0

/*
* Number of grids used to display the dungeon (vertically).
* Must be a multiple of 11, probably hard-coded to 22.
*/
#define SCREEN_HGT      22

/*
* Number of grids used to display the dungeon (horizontally).
* Must be a multiple of 33, probably hard-coded to 66.
*/
#define SCREEN_WID     80


#define DUNGEON_HGT    22
#define DUNGEON_WID    66

/*
* Maximum dungeon height in grids, must be a multiple of SCREEN_HGT,
* probably hard-coded to SCREEN_HGT * 3.
*/
#define MAX_HGT         66

/*
* Maximum dungeon width in grids, must be a multiple of SCREEN_WID,
* probably hard-coded to SCREEN_WID * 3.
*/
#define MAX_WID         198

/*
 * Maximum amount of Angband windows.
 */
#define ANGBAND_TERM_MAX 8

/*
* Total number of stores (see "store.c", etc)
*/
#define MAX_STORES      13

/*
* Road Directions
*/
#define ROAD_LEFT 0x01
#define ROAD_UP 0x02
#define ROAD_DOWN 0x04
#define ROAD_RIGHT 0x08

/*
* Store Types
*/

#define STORE_GENERAL   0
#define STORE_ARMOURY   1
#define STORE_WEAPON    2
#define STORE_TEMPLE    3
#define STORE_ALCHEMIST 4
#define STORE_MAGIC     5
#define STORE_BLACK     6
#define STORE_HOME      7
#define STORE_LIBRARY   8
#define STORE_INN       9
#define STORE_HALL      10
#define STORE_PAWN      11
#define STORE_BOOK_SWAP 12

/*
* Total number of owners per store (see "store.c", etc)
*/
#define MAX_OWNERS      16

/*
* Maximum number of player "sex" types (see "table.c", etc)
*/
#define MAX_SEXES            2


/* The number of "patrons" available (for Hell Knights and Devilspawn and Warlocks ) */
#define MAX_PATRON          16

/* Hell Knight: Reward types: */
#define REW_POLY_SLF    0
#define REW_GAIN_EXP    1
#define REW_LOSE_EXP    2
#define REW_GOOD_OBJ    3
#define REW_GREA_OBJ    4
#define REW_CHAOS_WP    5
#define REW_GOOD_OBS    6
#define REW_GREA_OBS    7
#define REW_TY_CURSE    8
#define REW_SUMMON_M    9
#define REW_H_SUMMON    10
#define REW_DO_HAVOC    11
#define REW_GAIN_ABL    12
#define REW_LOSE_ABL    13
#define REW_RUIN_ABL    14
#define REW_AUGM_ABL    15
#define REW_POLY_WND    16
#define REW_HEAL_FUL    17
#define REW_HURT_LOT    18
#define REW_CURSE_WP    19
#define REW_CURSE_AR    20
#define REW_PISS_OFF    21
#define REW_WRATH       22
#define REW_DESTRUCT    23
#define REW_GENOCIDE    24
#define REW_MASS_GEN    25
#define REW_DISPEL_C    26
#define REW_UNUSED_1    27
#define REW_UNUSED_2    28
#define REW_UNUSED_3    29
#define REW_UNUSED_4    30
#define REW_UNUSED_5    31
#define REW_IGNORE      32
#define REW_SER_UNDE    33
#define REW_SER_DEMO    34
#define REW_SER_MONS    35


/* "Activatable" corruptions must be in COR1_* */

#define COR1_SPIT_ACID                  0x00000001L
#define COR1_BR_FIRE                    0x00000002L
#define COR1_HYPN_GAZE                  0x00000004L
#define COR1_TELEKINES                  0x00000008L
#define COR1_VTELEPORT                  0x00000010L /* Voluntary teleport */
#define COR1_MIND_BLST                  0x00000020L
#define COR1_SLIME                      0x00000040L
#define COR1_VAMPIRISM                  0x00000080L
#define COR1_SMELL_MET                  0x00000100L
#define COR1_SMELL_MON                  0x00000200L
#define COR1_BLINK                      0x00000400L
#define COR1_EAT_ROCK                   0x00000800L
#define COR1_SWAP_POS                   0x00001000L
#define COR1_SHRIEK                     0x00002000L
#define COR1_ILLUMINE                   0x00004000L
#define COR1_DET_CURSE                  0x00008000L
#define COR1_BERSERK                    0x00010000L
#define COR1_POLYMORPH                  0x00020000L
#define COR1_MIDAS_TCH                  0x00040000L
#define COR1_GROW_MOLD                  0x00080000L
#define COR1_RESIST                     0x00100000L
#define COR1_EARTHQUAKE                 0x00200000L
#define COR1_EAT_MAGIC                  0x00400000L
#define COR1_WEIGH_MAG                  0x00800000L
#define COR1_STERILITY                  0x01000000L
#define COR1_PANIC_HIT                  0x02000000L
#define COR1_DAZZLE                     0x04000000L
#define COR1_EYE_BEAM                   0x08000000L
#define COR1_RECALL                     0x10000000L
#define COR1_BANISH                     0x20000000L
#define COR1_COLD_TOUCH                 0x40000000L
#define COR1_LAUNCHER                   0x80000000L

#define ABILITY_SPIT_ACID               0x00000101L
#define ABILITY_BREATHE_ELEMENTS        0x00000102L
#define ABILITY_DETECT_DOOR_TRAPS       0x00000103L

/* Randomly activating corruptions must be COR2_* */
#define COR2_BERS_RAGE                  0x00000001L
#define COR2_COWARDICE                  0x00000002L
#define COR2_RTELEPORT                  0x00000004L /* Random teleport, instability */
#define COR2_FORGET                     0x00000008L
#define COR2_HALLU                      0x00000010L
#define COR2_BRIMSTONE                  0x00000020L
#define COR2_POISON_FANGS               0x00000040L
#define COR2_CLAWS                      0x00000080L
#define COR2_LARGE_HORNS                0x00000100L
#define COR2_ATT_DEMON                  0x00000200L
#define COR2_PROD_MANA                  0x00000400L
#define COR2_SPEED_FLUX                 0x00000800L
#define COR2_BANISH_ALL                 0x00001000L
#define COR2_EAT_LIGHT                  0x00002000L
#define COR2_SMALL_HORNS                0x00004000L
#define COR2_ATT_ANIMAL                 0x00008000L
#define COR2_SPINES                     0x00010000L
#define COR2_RAW_CHAOS                  0x00020000L
#define COR2_NORMALITY                  0x00040000L
#define COR2_WRAITH                     0x00080000L
#define COR2_POLY_WOUND                 0x00100000L
#define COR2_WASTING                    0x00200000L
#define COR2_ATT_DRAGON                 0x00400000L
#define COR2_WEIRD_MIND                 0x00800000L
#define COR2_NAUSEA                     0x01000000L
#define COR2_PATRON                 0x02000000L
#define COR2_INTUITION                  0x04000000L
#define COR2_WARNING                    0x08000000L
#define COR2_INVULN                     0x10000000L
#define COR2_SP_TO_HP                   0x20000000L
#define COR2_HP_TO_SP                   0x40000000L
#define COR2_DISARM                     0x80000000L



/* Other corruptions will be mainly in COR3_* */

#define COR3_HYPER_STR                  0x00000001L
#define COR3_PUNY                       0x00000002L
#define COR3_HYPER_INT                  0x00000004L
#define COR3_IDIOTIC                    0x00000008L
#define COR3_RESILIENT                  0x00000010L
#define COR3_XTRA_FAT                   0x00000020L
#define COR3_ALBINO                     0x00000040L
#define COR3_FLESH_ROT                  0x00000080L
#define COR3_SILLY_VOI                  0x00000100L
#define COR3_FORKED_TONGUE              0x00000200L
#define COR3_ILL_NORM                   0x00000400L
#define COR3_GLOW_EYES                  0x00000800L
#define COR3_MAGIC_RES                  0x00001000L
#define COR3_STENCH	                    0x00002000L
#define COR3_INFRAVIS                   0x00004000L
#define COR3_GOAT_LEGS                  0x00008000L
#define COR3_SHORT_LEG                  0x00010000L
#define COR3_ELEC_TOUC                  0x00020000L
#define COR3_FIRE_BODY                  0x00040000L
#define COR3_WART_SKIN                  0x00080000L
#define COR3_SCALES                     0x00100000L
#define COR3_IRON_SKIN                  0x00200000L
#define COR3_WINGS                      0x00400000L
#define COR3_FEARLESS                   0x00800000L
#define COR3_REGEN                      0x01000000L
#define COR3_ESP                        0x02000000L
#define COR3_LIMBER                     0x04000000L
#define COR3_ARTHRITIS                  0x08000000L
#define COR3_RES_TIME                   0x10000000L
#define COR3_VULN_ELEM                  0x20000000L
#define COR3_MOTION                     0x40000000L
#define COR3_SUS_STATS                  0x80000000L

/* Mystic martial arts... */
# define MAX_MA 17
# define MA_KNEE 1
# define MA_SLOW 2

/* Mindcraft */
#define MAX_MINDCRAFT_POWERS  12

/* A hack for cave.c */

#define BMP_FIRST_PC_CLASS 164
#define BMP_FIRST_PC_RACE 128


/*
* Maximum array bounds for template based arrays
*/
#define MAX_F_IDX       103     /* Max size for "f_info[]" */
#define MAX_K_IDX       600     /* Max size for "k_info[]" */
#define MAX_A_IDX       150     /* Max size for "a_info[]" */
#define MAX_E_IDX       255     /* Max size for "e_info[]" */
#define MAX_R_IDX       700     /* Max size for "r_info[]" */
#define MAX_V_IDX       114     /* Max size for "v_info[]" Was 16*/


/*
* Maximum array bounds for entity list arrays
*/
#define MAX_O_IDX       800 /* Max size for "o_list[]" */
#define MAX_M_IDX       800 /* Max size for "m_list[]" */
#define MAX_P_IDX       800	/* Max size for "p_list[]" */

/*
* Maximum number of quests 
*/
#define MAX_QUESTS     2						 /* Max number of quests */


/*
* Maximum number of high scores in the high score file
*/
#define MAX_HISCORES    100


/*
* Maximum dungeon level.  The player can never reach this level
* in the dungeon, and this value is used for various calculations
* involving object and monster creation.  It must be at least 100.
* Setting it below 128 may prevent the creation of some objects.
*/
#define MAX_DEPTH       128


/*
* Maximum size of the "lite" array (see "cave.c")
* Note that the "lite radius" will NEVER exceed 5, and even if the "lite"
* was rectangular, we would never require more than 128 entries in the array.
*/
#define LITE_MAX 128

/*
* Maximum size of the "view" array (see "cave.c")
* Note that the "view radius" will NEVER exceed 20, and even if the "view"
* was octagonal, we would never require more than 1520 entries in the array.
*/
#define VIEW_MAX 1536

/*
* Maximum size of the "temp" array (see "cave.c")
* We must be as large as "VIEW_MAX" and "LITE_MAX" for proper functioning
* of "update_view()" and "update_lite()".  We must also be as large as the
* largest illuminatable room, but no room is larger than 800 grids.  We
* must also be large enough to allow "good enough" use as a circular queue,
* to calculate monster flow, but note that the flow code is "paranoid".
*/
#define TEMP_MAX 1536


/*
* Number of keymap modes
*/
#define KEYMAP_MODES	2

/*
* Mode for original keyset commands
*/
#define KEYMAP_MODE_ORIG	0

/*
* Mode for roguelike keyset commands
*/
#define KEYMAP_MODE_ROGUE	1


/*
* OPTION: Maximum number of macros (see "io.c")
* Default: assume at most 256 macros are used
*/
#define MACRO_MAX       256

/*
* OPTION: Maximum number of "quarks" (see "io.c")
* Default: assume at most 512 different inscriptions are used
*/
#define QUARK_MAX       768
/* Was 512... 256 quarks added for random artefacts */

/*
* OPTION: Maximum number of messages to remember (see "io.c")
* Default: assume maximal memorization of 2048 total messages
*/
#define MESSAGE_MAX     2048

/*
* OPTION: Maximum space for the message text buffer (see "io.c")
* Default: assume that each of the 2048 messages is repeated an
* average of three times, and has an average length of 48
*/
#define MESSAGE_BUF     32768


/*
* Maximum value storable in a "byte" (hard-coded)
*/
#define MAX_UCHAR       255

/*
* Maximum value storable in a "s16b" (hard-coded)
*/
#define MAX_SHORT       32767


/*
* Store constants
*/
#define STORE_INVEN_MAX 24              /* Max number of discrete objs in inven */
#define STORE_CHOICES   48              /* Number of items to choose stock from */
#define STORE_OBJ_LEVEL 5               /* Magic Level for normal stores */
#define STORE_TURNOVER  9               /* Normal shop turnover, per day */
#define STORE_MIN_KEEP  6               /* Min slots to "always" keep full */
#define STORE_MAX_KEEP  18              /* Max slots to "always" keep full */
#define STORE_SHUFFLE   21              /* 1/Chance (per day) of an owner changing */
#define STORE_TURNS             1000    /* Number of turns between turnovers */


/*
* Misc constants
*/
#define TOWN_DAWN               10000   /* Number of turns from dawn to dawn XXX */
#define BREAK_GLYPH             550             /* Rune of protection resistance */
#define BREAK_MINOR_GLYPH       99             /* For explosive runes */
#define BTH_PLUS_ADJ    3       /* Adjust BTH per plus-to-hit */
#define MON_MULT_ADJ    8               /* High value slows multiplication */
#define MON_SUMMON_ADJ  2               /* Adjust level of summoned creatures */
#define MON_DRAIN_LIFE  2               /* Percent of player exp drained per hit */
#define USE_DEVICE      3               /* x> Harder devices x< Easier devices     */

#define BIAS_ELEC 1                     /* "Biases" for random artefact gen */
#define BIAS_POIS 2
#define BIAS_FIRE 3
#define BIAS_COLD 4
#define BIAS_ACID 5
#define BIAS_STR 6
#define BIAS_INT 7
#define BIAS_WIS 8
#define BIAS_DEX 9
#define BIAS_CON 10
#define BIAS_CHA 11
#define BIAS_CHAOS 12
#define BIAS_PRIESTLY 13
#define BIAS_NECROMANTIC 14
#define BIAS_LAW 15
#define BIAS_ROGUE 16
#define BIAS_MAGE 17
#define BIAS_WARRIOR 18
#define BIAS_RANGER 19

/*
* There is a 1/20 (5%) chance of inflating the requested object_level
* during the creation of an object (see "get_obj_num()" in "object.c").
* Lower values yield better objects more often.
*/
#define GREAT_OBJ       20

/*
* There is a 1/50 (2%) chance of inflating the requested monster_level
* during the creation of a monsters (see "get_mon_num()" in "monster.c").
* Lower values yield harder monsters more often.
*/
#define NASTY_MON       50              /* 1/chance of inflated monster level */



/*
* Refueling constants
*/
#define FUEL_TORCH      5000    /* Maximum amount of fuel in a torch */
#define FUEL_LAMP       15000   /* Maximum amount of fuel in a lantern */


/*
* More maximum values
*/
#define MAX_SIGHT       20      /* Maximum view distance */
#define MAX_RANGE       18      /* Maximum range (spells, etc) */



/*
* There is a 1/160 chance per round of creating a new monster
*/
#define MAX_M_ALLOC_CHANCE      160

/*
* Normal levels get at least 14 monsters
*/
#define MIN_M_ALLOC_LEVEL       14

/*
* The town starts out with 4 residents during the day
*/
#define MIN_M_ALLOC_TD          4

/*
* The town starts out with 8 residents during the night
*/
#define MIN_M_ALLOC_TN          8


/*
* A monster can only "multiply" (reproduce) if there are fewer than 100
* monsters on the level capable of such spontaneous reproduction.  This
* is a hack which prevents the "m_list[]" array from exploding due to
* reproducing monsters.  Messy, but necessary.
*/
#define MAX_REPRO       100


/*
* Player constants
*/
#define PY_MAX_EXP      99999999L       /* Maximum exp */
#define PY_MAX_GOLD     999999999L      /* Maximum gold */
#define PY_MAX_LEVEL    50              /* Maximum level */

/*
* Player "food" crucial values
*/
#define PY_FOOD_MAX             15000   /* Food value (Bloated) */
#define PY_FOOD_FULL    10000   /* Food value (Normal) */
#define PY_FOOD_ALERT   2000    /* Food value (Hungry) */
#define PY_FOOD_WEAK    1000    /* Food value (Weak) */
#define PY_FOOD_FAINT   500             /* Food value (Fainting) */
#define PY_FOOD_STARVE  100             /* Food value (Starving) */

/*
* Player regeneration constants
*/
#define PY_REGEN_NORMAL         197             /* Regen factor*2^16 when full */
#define PY_REGEN_WEAK           98              /* Regen factor*2^16 when weak */
#define PY_REGEN_FAINT          33              /* Regen factor*2^16 when fainting */
#define PY_REGEN_HPBASE         1442    /* Min amount hp regen*2^16 */
#define PY_REGEN_MNBASE         524             /* Min amount mana regen*2^16 */

/* Possible realms that can be chosen; currently used only by birth.c
and tables.c --TY */
#define CH_NONE         0x00
#define CH_MIRACLES     0x01
#define CH_SORCERY      0x02
#define CH_NATURE       0x04
#define CH_CHAOS        0x08
#define CH_DEATH        0x10
#define CH_TAROT        0x20
#define CH_CHARMS       0x40
#define CH_SOMATIC      0x80
#define CH_DEMONIC      0x100

#define CH_ALL          0x1FF

#define REALM_NONE         0
#define REALM_MIRACLES     1
#define REALM_SORCERY      2
#define REALM_NATURE       3
#define REALM_CHAOS        4
#define REALM_DEATH        5
#define REALM_TAROT        6
#define REALM_CHARMS       7
#define REALM_SOMATIC      8
#define REALM_DEMONIC      9

#define MAX_REALM          9

#define MAX_EGO_REALMS     12

#define NO                 0
#define POOR               1
#define WORSE              2
#define SAME               3
#define BETTER             4
#define SUPER              5

#define BIT(x)            (1L << (x))

/*
* Maximum number of "normal" pack slots, and the index of the "overflow"
* slot, which can hold an item, but only temporarily, since it causes the
* pack to "overflow", dropping the "last" item onto the ground.  Since this
* value is used as an actual slot, it must be less than "INVEN_WIELD" (below).
* Note that "INVEN_PACK" is probably hard-coded by its use in savefiles, and
* by the fact that the screen can only show 23 items plus a one-line prompt.
*/
#define INVEN_PACK              23

/*
* Indexes used for various "equipment" slots (hard-coded by savefiles, etc).
*/
#define INVEN_WIELD     24
#define INVEN_BOW       25
#define INVEN_LEFT      26
#define INVEN_RIGHT     27
#define INVEN_NECK      28
#define INVEN_LITE      29
#define INVEN_BODY      30
#define INVEN_OUTER     31
#define INVEN_ARM       32
#define INVEN_HEAD      33
#define INVEN_HANDS     34
#define INVEN_FEET      35
#define INVEN_POUCH_1    36
#define INVEN_POUCH_2    37
#define INVEN_POUCH_3    38
#define INVEN_POUCH_4    39
#define INVEN_POUCH_5    40
#define INVEN_POUCH_6    41

/*
* Total number of inventory slots (hard-coded).
*/
#define INVEN_TOTAL     42


/*
* A "stack" of items is limited to less than 100 items (hard-coded).
*/
#define MAX_STACK_SIZE                  100

/*
 * Maximum number of objects allowed in a single dungeon grid.
 *
 * The main-screen has a minimum size of 24 rows, so we can always
 * display 23 objects + 1 header line.
 */
#define MAX_FLOOR_STACK			23

/*
* Indexes of the various "stats" (hard-coded by savefiles, etc).
*/
#define A_STR   0
#define A_INT   1
#define A_WIS   2
#define A_DEX   3
#define A_CON   4
#define A_CHA   5

/* Stat count for loops on stats, who knows how many stats we might have one day */

#define STAT_COUNT 6

/*
* Player sex constants (hard-coded by save-files, arrays, etc)
*/
#define SEX_FEMALE              0
#define SEX_MALE                1

/*
* Maximum number of player "class" types (see "table.c", etc)
*/
#define MAX_CLASS            16

/*
* Player class constants (hard-coded by save-files, arrays, etc)
*/
#define CLASS_WARRIOR      0
#define CLASS_MAGE         1
#define CLASS_ROGUE        2
#define CLASS_PRIEST       3
#define CLASS_RANGER       4
#define CLASS_PALADIN      5
#define CLASS_BLACK_KNIGHT 6
#define CLASS_CHAOS_KNIGHT 7
#define CLASS_HELL_KNIGHT  8
#define CLASS_WARRIOR_MAGE 9
#define CLASS_HIGH_MAGE    10
#define CLASS_BLOOD_MAGE   11
#define CLASS_WARLOCK      12
#define CLASS_MYSTIC       13
#define CLASS_ORPHIC       14
#define CLASS_DRUID        15


#define COUNT_LINES  14
#define COUNT_SEXES  2
#define COUNT_RACES  4
#define COUNT_SUBRACES 28
#define COUNT_SIGNS 5
#define COUNT_AFFLICTIONS 5
#define COUNT_CORRUPTIONS 96

#define LADY 0
#define GENTLEMAN 1

#define R_HUMAN  0
#define R_FAERIE 1
#define R_SPAWN  2
#define R_ELDER  3

/*
 * Player race constants (hard-coded by save-files, arrays, etc)
 */

#define FLORENTIAN 	0
#define GIPSY		1
#define NORDIC		2
#define ATLANTIAN	3
#define DWARF		4
#define ELF			5
#define OGRE		6
#define TROLL		7
#define GIANT		8
#define TITAN		9	
#define NEPHILIM	10
#define HUMAN		11 /*Special case for shop owners*/
#define AFFLICTED	11 /*Special case to indicate these guys dont have a birthsign*/
#define FAE 		12
#define GNOME		13
#define LEPRECHAUN	14
#define KOBOLD		15	
#define DEVILSPAWN	16
#define IMP			17
#define SUCCUBUS	18
#define LILI		19	
#define ELDER		20
#define GUARDIAN	21
#define HORROR		22
#define VAMPIRE     23
#define WEREWOLF    24
#define SKELETON    25
#define MUMMY       26
#define SPECTRE     27

/* Eh this is hackish, but at least you wont be able to miss out when you created new races*/

#define BG_FLORENTIAN    1<<(FLORENTIAN +1)
#define BG_GIPSY         1<<(GIPSY      +1)
#define BG_NORDIC        1<<(NORDIC     +1)
#define BG_ATLANTIAN     1<<(ATLANTIAN  +1)
#define BG_DWARF         1<<(DWARF      +1)
#define BG_ELF           1<<(ELF        +1)
#define BG_OGRE          1<<(OGRE       +1)
#define BG_TROLL         1<<(TROLL      +1)
#define BG_GIANT         1<<(GIANT      +1)
#define BG_TITAN         1<<(TITAN      +1)
#define BG_NEPHILIM      1<<(NEPHILIM   +1)
#define BG_HUMAN         1<<(HUMAN      +1)
#define BG_AFFLICTED     1<<(AFFLICTED  +1)
#define BG_FAE           1<<(FAE        +1)
#define BG_GNOME         1<<(GNOME      +1)
#define BG_LEPRECHAUN    1<<(LEPRECHAUN +1)
#define BG_KOBOLD        1<<(KOBOLD     +1)
#define BG_DEVILSPAWN    1<<(DEVILSPAWN +1)
#define BG_IMP           1<<(IMP        +1)
#define BG_SUCCUBUS      1<<(SUCCUBUS   +1)
#define BG_LILI          1<<(LILI       +1)
#define BG_ELDER         1<<(ELDER      +1)
#define BG_GUARDIAN      1<<(GUARDIAN   +1)
#define BG_HORROR        1<<(HORROR     +1)
#define BG_VAMPIRE       1<<(VAMPIRE    +1)
#define BG_WEREWOLF      1<<(WEREWOLF   +1)
#define BG_SKELETON      1<<(SKELETON   +1)
#define BG_MUMMY         1<<(MUMMY      +1)
#define BG_SPECTRE       1<<(SPECTRE    +1) 

#define SIGN_FREE    0
#define SIGN_DRACO   1
#define SIGN_SERPENS 2
#define SIGN_PLUTUS  3
#define SIGN_MORUI   4

/*** Screen Locations ***/

/*
* Some screen locations for various display routines
* Currently, row 8 and 15 are the only "blank" rows.
* That leaves a "border" around the "stat" values.
*/

#define ROW_STATUS              23

#define ROW_INFO                22
#define COL_INFO                0       /* "Monster Health Bar" */


#define ROW_TIME                1
#define COL_TIME               0       /* 6:00AM */

#define ROW_DATE               2
#define COL_DATE               0       /* <template name> */

#define ROW_TITLE               3
#define COL_TITLE               0       /* <title> or <mode> */

#define ROW_LEVEL               4
#define COL_LEVEL               0       /* "LEVEL xxxxxx" */

#define ROW_EXP                 5
#define COL_EXP                 0       /* "EXP xxxxxxxx" */

#define ROW_GOLD                6
#define COL_GOLD                0       /* "AU xxxxxxxxx" */

#define ROW_EQUIPPY             7
#define COL_EQUIPPY             0       /* equippy chars */

#define ROW_STAT                8
#define COL_STAT                0       /* "xxx   xxxxxx" */

#define ROW_AC                  15
#define COL_AC                  0       /* "Cur AC xxxxx" */

#define ROW_MAXHP               16
#define COL_MAXHP               0       /* "Max HP xxxxx" */

#define ROW_CURHP               17
#define COL_CURHP               0       /* "Cur HP xxxxx" */

#define ROW_MAXSP               18
#define COL_MAXSP               0       /* "Max SP xxxxx" */

#define ROW_CURSP               19
#define COL_CURSP               0       /* "Cur SP xxxxx" */

#define ROW_CUT                 21
#define COL_CUT                 0       /* <cut> */

#define ROW_STUN                22
#define COL_STUN                0       /* <stun> */

#define ROW_HUNGRY              23
#define COL_HUNGRY              0       /* "Weak" / "Hungry" / "Full" / "Gorged" */

#define ROW_BLIND               23
#define COL_BLIND               7       /* "Blind" */

#define ROW_CONFUSED    23
#define COL_CONFUSED    13      /* "Confused" */

#define ROW_AFRAID              23
#define COL_AFRAID              22      /* "Afraid" */

#define ROW_POISONED    23
#define COL_POISONED    29      /* "Poisoned" */

#define ROW_STATE               23
#define COL_STATE               38      /* <state> */

#define ROW_SPEED               23
#define COL_SPEED               49      /* "Slow (-NN)" or "Fast (+NN)" */

#define ROW_STUDY               23
#define COL_STUDY               58      /* "Study" */

#define ROW_DEPTH               23
#define COL_DEPTH               67      /* "Lev NNN" / "NNNN ft" */



/*** Terrain Feature Indexes (see "lib/edit/f_info.txt") ***/

/* Nothing */
#define FEAT_NONE               0x00

/* Various */
#define FEAT_FLOOR              0x01
#define FEAT_INVIS              0x02
#define FEAT_GLYPH              0x03
#define FEAT_OPEN               0x04
#define FEAT_BROKEN             0x05
#define FEAT_LESS               0x06
#define FEAT_MORE               0x07
#define FEAT_PATH                0x08

/* Traps */
#define FEAT_TRAP_HEAD  0x10
#define FEAT_TRAP_TAIL  0x1F

/* Doors */
#define FEAT_DOOR_HEAD  0x20
#define FEAT_DOOR_TAIL  0x2F

/* Extra */
#define FEAT_SECRET             0x30
#define FEAT_RUBBLE             0x31

/* Seams */
#define FEAT_MAGMA              0x32
#define FEAT_QUARTZ             0x33
#define FEAT_MAGMA_H    0x34
#define FEAT_QUARTZ_H   0x35
#define FEAT_MAGMA_K    0x36
#define FEAT_QUARTZ_K   0x37

/* Walls */
#define FEAT_WALL_EXTRA 0x38
#define FEAT_WALL_INNER 0x39
#define FEAT_WALL_OUTER 0x3A
#define FEAT_WALL_SOLID 0x3B
#define FEAT_PERM_BUILDING 0x3C
#define FEAT_PERM_INNER 0x3D
#define FEAT_PERM_OUTER 0x3E
#define FEAT_PERM_SOLID 0x3F
#define FEAT_MINOR_GLYPH 0x40
#define FEAT_PATTERN_START 0x41
#define FEAT_PATTERN_1  0x42
#define FEAT_PATTERN_2  0x43
#define FEAT_PATTERN_3  0x44
#define FEAT_PATTERN_4  0x45
#define FEAT_PATTERN_END 0x46
#define FEAT_PATTERN_OLD 0x47
#define FEAT_PATTERN_XTRA1 0x48
#define FEAT_PATTERN_XTRA2 0x49

/* Beginning of Dis ( Dis contains shielded levels and no vaults ) */
#define DIS_START 5
#define DIS_END   27


/* Shops */
#define FEAT_SHOP_HEAD        0x4A
#define FEAT_SHOP_TAIL         0x55

/* Other Surface Stuff */
#define FEAT_GATE                    0x60
#define FEAT_WATER                 0x61
#define FEAT_TREE                     0x62
#define FEAT_BUSH                    0x63

/*** Artifact indexes (see "lib/edit/a_info.txt") ***/


/* Lites  ART_GALADRIEL , ART_GEM_SEEING ,  ART_INSIGHT */ 
#define ART_BEATRICE     1
#define ART_EOS          2
#define ART_HIPPO        3

/* Amulets  ART_PURITY , ART_INQUISITION , ART_DWARVES */
#define ART_DOOM            4
#define ART_AMULET_RAPHAEL  5
#define ART_AMULET_MICHAEL  6
#define ART_NEPHILIM        7

/* Rings ART_MAGIC , ART_BAST ,  ART_ELEMFIRE , ART_ELEMICE , ART_ELEMSTORM , ART_ONE_RING*/
#define ART_RING_GEORGE     8
#define ART_RING_GABRIEL    9
#define ART_RING_RAPHAEL    10
#define ART_RING_MICHAEL    11
#define ART_EMMANUEL        13
#define ART_FIRST           14

/*
ART_KOBOLD -> ART_ALASTOR
ART_WYVERNSCALE - > ART_WHIRLWIND
ART_HEARTGUARD -> ART_SABNOCK
ART_OGRELORDS -> ART_PRAVUIL
ART_SERPENTS -> ART_SEIRIM
ART_VAMPLORD ->  ART_ROBE_MICHAEL
ART_ORCS -> VEPAR
*/
#define ART_SABNOCK         15
#define ART_ALASTOR         16
#define ART_WHIRLWIND       17
#define ART_PRAVUIL         18
#define ART_SEIRIM          21
#define ART_ROBE_MICHAEL    22
#define ART_VEPAR           25

/* ART_SOULKEEPER - > ART_GAEP , ART_ZIMINAR , ART_CORSON , ART_AMAYMON */
#define ART_GAEP            26
#define ART_ZIMINAR         27
#define ART_CORSON          28
#define ART_AMAYMON         29

/* Dragon Scale */
/* ART_RAZORBACK - > ART_BAPHOMET + ART_ASMODAI */
#define ART_BAPHOMET        30
#define ART_ASMODAI         31

/* ART_BLADETURNER -> ART_SAMAEL + ART_ABADDON + ART_BLOOD_MICHAEL */

#define ART_SAMAEL          32
#define ART_ABADDON         33
#define ART_BLOOD_MICHAEL   34

/*#define ART_GODS                20 -> Has become Halphas and Naberius */

/* Shields */
#define ART_SHIELD_MICHAEL  35
#define ART_SHIELD_ELEMENTS 36
#define ART_SHIELD_AGES     37

/* Helms and Crowns 
ART_UNIVERSE -> ART_SEVENTH
ART_MISERY -> ART_MISERY
ART_ORPHIC - > ART_SOLOMON
ART_HOLINESS -> ART_AUGUSTIN
ART_HAMMERHAND -> ART_GALLU
ART_POWER -> ART_LAMMASU
*/

#define ART_AUGUSTIN        38
#define ART_SOLOMON         39
#define ART_GALLU           40
#define ART_MASK            41
#define ART_SKULLKEEPER     42
#define ART_MISERY          43
#define ART_LAMMASU         44
#define ART_SUN             45
#define ART_SEVENTH         46

/* Cloaks 
ART_SHADE - > ART_SIMPLE
ART_SWASHBUCKLER -> ART_BARD
ART_DARKNESS -> ART_DRAEBOR
*/
#define ART_SHIFTER         47
#define ART_SIMPLE          48
#define ART_JOSEPH          49
#define ART_DRAEBOR         50
#define ART_BARD            51
#define ART_LIFE            52
#define ART_LUCIFUGE        53
#define ART_FROSTPLAINS     53

/* Gloves 
ART_CALFSKIN -> ART_MALPHAS
ART_WHITESPARK -> ART_FURFICER
ART_COMBAT -> ART_GRIMREAPER
*/
#define ART_MALPHAS         55
#define ART_LIGHT           56
#define ART_IRONFIST        57
#define ART_GHOULS          58
#define ART_FURFICER        59
#define ART_DEAD            60
#define ART_THANOS          61
#define ART_GRIMREAPER      62

/* Boots 
ART_TRAVEL -> ART_BOOTS_GABRIEL , ART_BOOTS_FURCIFER
*/
#define ART_DANCING         63
#define ART_BLACKREAVER     64
#define ART_BOOTS_FURCIFER  65
#define ART_BOOTS_GABRIEL   66          

/* BLADES & Co
ART_HOPE -> ART_COCYTUS
ART_FAITH -> ART_DAGGER_INFERNO
ART_CHARITY -> ART_DAGGER_FURCIFER
ART_THOTH -> ART_KINSLAYER
*/

#define ART_COCYTUS         67
#define ART_DAGGER_INFERNO  68
#define ART_DAGGER_FURCIFER 69
#define ART_KINSLAYER       70
#define ART_FROST           71
#define ART_VALEFAR         72
#define ART_HOMER           73
#define ART_BARBATOS        74
#define ART_MERLIN          75
#define ART_SOULSWORD       76
#define ART_GUSION          77
#define ART_SITRI           78
#define ART_OROBAS          79
#define ART_BRIGHTBLADE     80
#define ART_BLACKICE        81
#define ART_ANDROMALIUS     82
#define ART_RASHAVERAK      83
#define ART_SWORD_FURCIFER  86
#define ART_MICHAEL         87
#define ART_DRAGONSLAYER    91
#define ART_FIRETONGUE      92
#define ART_AZRAEL          94
#define ART_DAWN            95
#define ART_ASTAROTH        96
 
/* Polearms */

#define ART_ODIN            98
#define ART_DESTINY         99
#define ART_ELIGOR          102
#define ART_PHENEX          106
#define ART_MORNINGSTAR     107
#define ART_BELETH          108
#define ART_TROLLS          113
#define ART_RONOVE          115
#define ART_TRITONS         117
#define ART_HAMMER_AMAYMON  118
#define ART_HAMMER_ABADDON  120

/* Quarterstafs staves stavens ? Grin ;) */

#define ART_FIRESTAFF       121
#define ART_ERIRIL          122
#define ART_JUSTICE         123
#define ART_ATAL            124

/* Bows */

#define ART_BOWASSASSIN     126
#define ART_SURESHOT        127
#define ART_DEATH           128

/*** Ego-Item indexes (see "lib/edit/e_info.txt") ***/

/* Nothing */
/* xxx */
/* xxx */
/* xxx */

/* Body Armor */
#define EGO_RESIST_ACID         4
#define EGO_RESIST_ELEC         5
#define EGO_RESIST_FIRE         6
#define EGO_RESIST_COLD         7
#define EGO_HEAVEN              8
#define EGO_ELVENKIND           9
/* xxx */
#define EGO_PERMANENCE          11
/* xxx */
/* xxx */
/* xxx */
/* xxx */

/* Shields */
#define EGO_ENDURE_ACID         16
#define EGO_ENDURE_ELEC         17
#define EGO_ENDURE_FIRE         18
#define EGO_ENDURE_COLD         19
#define EGO_ENDURANCE           20
#define EGO_REFLECTION          21
/* xxx */
/* xxx */

/* Crowns and Helms */
#define EGO_INTELLIGENCE        24
#define EGO_WISDOM                      25
#define EGO_BEAUTY                      26
#define EGO_MAGI                        27
#define EGO_MIGHT                       28
#define EGO_LORDLINESS          29
#define EGO_SEEING                      30
#define EGO_INFRAVISION         31
#define EGO_LITE                        32
#define EGO_TELEPATHY           33
#define EGO_REGENERATION        34
#define EGO_TELEPORTATION       35
#define EGO_STUPIDITY           36
#define EGO_NAIVETY                     37
#define EGO_UGLINESS            38
#define EGO_SICKLINESS          39

/* Cloaks */
#define EGO_PROTECTION          40
#define EGO_STEALTH                     41
#define EGO_AMAN                        42
#define EGO_AURA_FIRE                   43
#define EGO_ENVELOPING          44
#define EGO_VULNERABILITY       45
#define EGO_IRRITATION          46
#define EGO_AURA_ELEC               47

/* Gloves */
#define EGO_FREE_ACTION         48
#define EGO_SLAYING                     49
#define EGO_AGILITY                     50
#define EGO_POWER                       51
/* xxx */
/* xxx */
#define EGO_WEAKNESS            54
#define EGO_CLUMSINESS          55

/* Boots */
#define EGO_SLOW_DESCENT        56
#define EGO_QUIET                       57
#define EGO_MOTION                      58
#define EGO_SPEED                       59
/* xxx */
#define EGO_NOISE                       61
#define EGO_SLOWNESS            62
#define EGO_ANNOYANCE           63

/* Weapons */
#define EGO_HA                          64
#define EGO_DF                          65
#define EGO_BLESS_BLADE         66
/* xxx */
#define EGO_ANGELIC                        68
#define EGO_ATTACKS                     69
#define EGO_SLAYING_WEAPON              70
#define EGO_DEMONIC             71
/* xxx */
#define EGO_BRAND_ACID          72
#define EGO_BRAND_ELEC          73
#define EGO_BRAND_FIRE          74
#define EGO_BRAND_COLD          75
#define EGO_BRAND_POIS          76
#define EGO_CHAOTIC             77
#define EGO_SHARPNESS           78
#define EGO_EARTHQUAKES         79
#define EGO_SLAY_ANIMAL         80
#define EGO_SLAY_EVIL           81
#define EGO_SLAY_UNDEAD         82
#define EGO_SLAY_DEMON          83
#define EGO_SLAY_ANGEL          84
#define EGO_KILL_ANGEL          85
#define EGO_SLAY_GIANT          86
#define EGO_SLAY_DRAGON         87
#define EGO_KILL_ANIMAL         88
#define EGO_KILL_EVIL           89
#define EGO_KILL_UNDEAD         90
#define EGO_KILL_DEMON          83
/* EGO_KILL_ORC */
#define EGO_KILL_XANGEL         84 
/* EGO_KILL_TROLL */
#define EGO_KILL_SINNER         85
#define EGO_KILL_GIANT          86
#define EGO_KILL_DRAGON         95
#define EGO_VAMPIRIC            96
/* xxx */
/* xxx */
#define EGO_PLANAR               98
#define EGO_PATTERN             99
#define EGO_DIGGING                     100
/* xxx */
#define EGO_HELL                      102
/* xxx */

/* Bows */
#define EGO_ACCURACY            104
#define EGO_VELOCITY            105
/* xxx */
/* xxx */
#define EGO_EXTRA_MIGHT         108
#define EGO_EXTRA_SHOTS         109
/* xxx */
/* xxx */

/* Ammo */
#define EGO_HURT_ANIMAL         112
#define EGO_HURT_EVIL           113
#define EGO_HOLY_FLAME          114
#define EGO_ANGEL_BANE          115
/* xxx */
/* xxx */
/* xxx */
/* xxx */
/* xxx */
#define EGO_HURT_DRAGON         119
#define EGO_SLAYING_BOLT        120
#define EGO_LIGHTNING_BOLT      121
#define EGO_FLAME                       122
#define EGO_FROST                       123
#define EGO_WOUNDING            124
#define EGO_BACKBITING          125
#define EGO_SHATTERED           126
#define EGO_BLASTED                     127

/* Orbs */

#define EGO_ORB_FLAME			128
#define EGO_ORB_FROST			129
#define EGO_ORB_ACID			130
#define EGO_ORB_LIGHTNING		131
#define EGO_ORB_LIGHT			132
#define EGO_ORB_DARKNESS		133
#define EGO_ORB_LIFE			134
#define EGO_ORB_SIGHT			135
#define EGO_ORB_COURAGE			136
#define EGO_ORB_VENOM			137
#define EGO_ORB_CLARITY			138
#define EGO_ORB_SOUND			139
#define EGO_ORB_CHAOS			140
#define EGO_ORB_SHARDS			141
#define EGO_ORB_UNLIFE			142
#define EGO_ORB_STABILITY		143
#define EGO_ORB_MAGIC			144
#define EGO_ORB_FREEDOM			145
#define EGO_ORB_STRENGTH		146
#define EGO_ORB_INTELLIGENCE	147
#define EGO_ORB_WISDOM			148
#define EGO_ORB_DEXTERITY		149
#define EGO_ORB_CONSTITUTION	150
#define EGO_ORB_CHARISMA		151
#define EGO_ORB_LIGHTNESS		152
#define EGO_ORB_INSIGHT			153
#define EGO_ORB_MIND			154
#define EGO_ORB_SUSTENANCE		155
#define EGO_ORB_HEALTH			156
#define EGO_ORB_POWER			157
#define EGO_ORB_IRRITATION		158
#define EGO_ORB_INSTABILITY		159
#define EGO_ELEMENTS_MINCHIATE  160

/* Activation effects for random artefacts */
#define ACT_SUNLIGHT            1
#define ACT_BO_MISS_1           2
#define ACT_BA_POIS_1           3
#define ACT_BO_ELEC_1           4
#define ACT_BO_ACID_1           5
#define ACT_BO_COLD_1           6
#define ACT_BO_FIRE_1           7
#define ACT_BA_COLD_1           8
#define ACT_BA_FIRE_1           9
#define ACT_DRAIN_1             10
#define ACT_BA_COLD_2           11
#define ACT_BA_ELEC_2           12
#define ACT_DRAIN_2             13
#define ACT_VAMPIRE_1           14
#define ACT_BO_MISS_2           15
#define ACT_BA_FIRE_2           16
#define ACT_BA_COLD_3           17
#define ACT_BA_ELEC_3           18
#define ACT_WHIRLWIND           19
#define ACT_VAMPIRE_2           20
#define ACT_CALL_CHAOS          21
#define ACT_SHARD              22
#define ACT_DISP_EVIL           23
#define ACT_BA_MISS_3           24
#define ACT_DISP_GOOD           25
/* 26 - 50 unused */
#define ACT_CONFUSE             51
#define ACT_SLEEP               52
#define ACT_QUAKE               53
#define ACT_TERROR              54
#define ACT_TELE_AWAY           55
#define ACT_BANISH_EVIL         56
#define ACT_GENOCIDE            57
#define ACT_MASS_GENO           58
/* 59 - 64 unused */
#define ACT_CHARM_ANIMAL        65
#define ACT_CHARM_UNDEAD        66
#define ACT_CHARM_OTHER         67
#define ACT_CHARM_ANIMALS       68
#define ACT_CHARM_OTHERS        69
#define ACT_SUMMON_ANIMAL       70
#define ACT_SUMMON_PHANTOM      71
#define ACT_SUMMON_ELEMENTAL    72
#define ACT_SUMMON_DEMON        73
#define ACT_SUMMON_UNDEAD       74
/* 75 - 80 unused */
#define ACT_CURE_LW             81
#define ACT_CURE_MW             82
#define ACT_CURE_POISON         83
#define ACT_REST_LIFE           84
#define ACT_REST_ALL            85
#define ACT_CURE_700            86
#define ACT_CURE_1000           87
/* 88 - 90 unused */
#define ACT_ESP                 91
#define ACT_BERSERK             92
#define ACT_PROT_EVIL           93
#define ACT_RESIST_ALL          94
#define ACT_SPEED               95
#define ACT_XTRA_SPEED          96
#define ACT_WRAITH              97
#define ACT_INVULN              98
/* 99 - 110 unused */
#define ACT_LIGHT               111
#define ACT_MAP_LIGHT           112
#define ACT_DETECT_ALL          113
#define ACT_DETECT_XTRA         114
#define ACT_ID_FULL             115
#define ACT_ID_PLAIN            116
#define ACT_RUNE_EXPLO          117
#define ACT_RUNE_PROT           118
#define ACT_SATIATE             119
#define ACT_DEST_DOOR          120
#define ACT_STONE_MUD           121
#define ACT_RECHARGE            122
#define ACT_ALCHEMY             123
#define ACT_DIM_DOOR            124
#define ACT_TELEPORT            125
#define ACT_RECALL              126
/* 127 -> unused */

/*** Object "tval" and "sval" codes ***/


/*
* The values for the "tval" field of various objects.
*
* This value is the primary means by which items are sorted in the
* player inventory, followed by "sval" and "cost".
*
* Note that a "BOW" with tval = 19 and sval S = 10*N+P takes a missile
* weapon with tval = 16+N, and does (xP) damage when so combined.  This
* fact is not actually used in the source, but it kind of interesting.
*
* Note that as of 2.7.8, the "item flags" apply to all items, though
* only armour and weapons and a few other items use any of these flags.
*/

#define TV_SKELETON      1      /* Skeletons ('s') */
#define TV_BOTTLE                2      /* Empty bottles ('!') */
#define TV_JUNK          3      /* Sticks, Pottery, etc ('~') */
#define TV_SPIKE         5      /* Spikes ('~') */
#define TV_CHEST         7      /* Chests ('~') */
#define TV_SHOT         16      /* Ammo for slings */
#define TV_ARROW        17      /* Ammo for bows */
#define TV_BOLT         18      /* Ammo for x-bows */
#define TV_BOW          19      /* Slings/Bows/Xbows */
#define TV_DIGGING      20      /* Shovels/Picks */
#define TV_HAFTED       21      /* Priest Weapons */
#define TV_POLEARM      22      /* Axes and Pikes */
#define TV_SWORD        23      /* Edged Weapons */
#define TV_BOOTS        30      /* Boots */
#define TV_GLOVES       31      /* Gloves */
#define TV_HELM         32      /* Helms */
#define TV_CROWN        33      /* Crowns */
#define TV_SHIELD       34      /* Shields */
#define TV_CLOAK        35      /* Cloaks */
#define TV_SOFT_ARMOR   36      /* Soft Armor */
#define TV_HARD_ARMOR   37      /* Hard Armor */
#define TV_DRAG_ARMOR   38      /* Dragon Scale Mail */
#define TV_LITE         39      /* Lites (including Specials) */
#define TV_AMULET       40      /* Amulets (including Specials) */
#define TV_RING         45      /* Rings (including Specials) */
#define TV_STAFF        55
#define TV_WAND         65
#define TV_ROD          66
#define TV_SCROLL       70
#define TV_POTION       75
#define TV_FLASK        77
#define TV_FOOD         80
#define TV_MIRACLES_BOOK 90
#define TV_SORCERY_BOOK  91
#define TV_BOOK_REALM1	 91  
#define TV_NATURE_BOOK   92
#define TV_CHAOS_BOOK    93
#define TV_DEATH_BOOK    94
#define TV_BOOK_REALM2	 94
#define TV_TAROT_BOOK    95
#define TV_CHARMS_BOOK   96
#define TV_SOMATIC_BOOK  97
#define TV_DEMONIC_BOOK  98
#define TV_GOLD         100     /* Gold can only be picked up by players */



/* The "sval" codes for TV_SHOT/TV_ARROW/TV_BOLT */
#define SV_AMMO_LIGHT           0       /* pebbles */
#define SV_AMMO_NORMAL          1       /* shots, arrows, bolts */
#define SV_AMMO_HEAVY           2       /* seeker arrows and bolts */

/* The "sval" codes for TV_BOW (note information in "sval") */
#define SV_SLING                        2       /* (x2) */
#define SV_SHORT_BOW            12      /* (x2) */
#define SV_LONG_BOW                     13      /* (x3) */
#define SV_LIGHT_XBOW           23      /* (x3) */
#define SV_HEAVY_XBOW           24      /* (x4) */

/* The "sval" codes for TV_DIGGING */
#define SV_SHOVEL                       1
#define SV_GNOMISH_SHOVEL       2
#define SV_DWARVEN_SHOVEL       3
#define SV_PICK                         4
#define SV_ORCISH_PICK          5
#define SV_DWARVEN_PICK         6

/* The "sval" values for TV_HAFTED */
#define SV_WHIP                                 2       /* 1d6 */
#define SV_QUARTERSTAFF                 3       /* 1d9 */
#define SV_MACE                                 5       /* 2d4 */
#define SV_BALL_AND_CHAIN               6       /* 2d4 */
#define SV_WAR_HAMMER                   8       /* 3d3 */

#define SV_MORNING_STAR                 12      /* 2d6 */
#define SV_FLAIL                                13      /* 2d6 */
#define SV_LEAD_FILLED_MACE             15      /* 3d4 */
#define SV_TWO_HANDED_FLAIL             18      /* 3d6 */
#define SV_MACE_OF_DISRUPTION   20      /* 5d8 */
#define SV_WORLDS                                50      /* 3d4 */

/* The "sval" values for TV_POLEARM */
#define SV_SPEAR                                2       /* 1d6 */
#define SV_AWL_PIKE                             4       /* 1d8 */
#define SV_TRIDENT                              5       /* 1d9 */
#define SV_PIKE                                 8       /* 2d5 */
#define SV_BEAKED_AXE                   10      /* 2d6 */
#define SV_BROAD_AXE                    11      /* 2d6 */
#define SV_GLAIVE                               13      /* 2d6 */
#define SV_HALBERD                              15      /* 3d4 */
#define SV_SCYTHE                               17      /* 5d3 */
#define SV_LANCE                                20      /* 2d8 */
#define SV_BATTLE_AXE                   22      /* 2d8 */
#define SV_GREAT_AXE                    25      /* 4d4 */
#define SV_LOCHABER_AXE                 28      /* 3d8 */
#define SV_SCYTHE_OF_SLICING    30      /* 8d4 */

/* The "sval" codes for TV_SWORD */
#define SV_BROKEN_DAGGER                1       /* 1d1 */
#define SV_BROKEN_SWORD                 2       /* 1d2 */
#define SV_DAGGER                               4       /* 1d4 */
#define SV_PARRYING_DAGGER                  5       /* 1d5 */
#define SV_RAPIER                               7       /* 1d6 */
#define SV_SMALL_SWORD                  8       /* 1d6 */
#define SV_SHORT_SWORD                  10      /* 1d7 */
#define SV_SABRE                                11      /* 1d7 */
#define SV_CUTLASS                              12      /* 1d7 */
#define SV_TULWAR                               15      /* 2d4 */
#define SV_BROAD_SWORD                  16      /* 2d5 */
#define SV_LONG_SWORD                   17      /* 2d5 */
#define SV_SCIMITAR                             18      /* 2d5 */
#define SV_GLADIUS                21      /* 3d4 */
#define SV_TWO_HANDED_SWORD             25      /* 3d6 */
#define SV_EXECUTIONERS_SWORD   28      /* 4d5 */
#define SV_BLADE_OF_CHAOS               30      /* 6d5 */

/* The "sval" codes for TV_SHIELD */
#define SV_SMALL_LEATHER_SHIELD         2
#define SV_SMALL_METAL_SHIELD           3
#define SV_LARGE_LEATHER_SHIELD         4
#define SV_LARGE_METAL_SHIELD           5
#define SV_DRAGON_SHIELD                6
#define SV_SHIELD_OF_DEFLECTION         10

/* The "sval" codes for TV_HELM */
#define SV_HARD_LEATHER_CAP             2
#define SV_METAL_CAP                    3
#define SV_IRON_HELM                    5
#define SV_STEEL_HELM                   6
#define SV_DRAGON_HELM                  7
#define SV_IRON_CROWN                   10
#define SV_GOLDEN_CROWN                 11
#define SV_JEWELED_CROWN                12
#define SV_SEVENTH                      50

/* The "sval" codes for TV_BOOTS */
#define SV_PAIR_OF_SOFT_LEATHER_BOOTS   2
#define SV_PAIR_OF_HARD_LEATHER_BOOTS   3
#define SV_PAIR_OF_METAL_SHOD_BOOTS             6

/* The "sval" codes for TV_CLOAK */
#define SV_CLOAK                                        1
#define SV_ELVEN_CLOAK                          2
#define SV_SHADOW_CLOAK                         6

/* The "sval" codes for TV_GLOVES */
#define SV_SET_OF_LEATHER_GLOVES        1
#define SV_SET_OF_GAUNTLETS                     2
#define SV_SET_OF_CESTI                         5

/* The "sval" codes for TV_SOFT_ARMOR */
#define SV_FILTHY_RAG                           1
#define SV_ROBE                                         2
#define SV_SOFT_LEATHER_ARMOR           4
#define SV_SOFT_STUDDED_LEATHER         5
#define SV_HARD_LEATHER_ARMOR           6
#define SV_HARD_STUDDED_LEATHER         7
#define SV_LEATHER_SCALE_MAIL           11

/* The "sval" codes for TV_HARD_ARMOR */
#define SV_RUSTY_CHAIN_MAIL                     1       /* 14- */
#define SV_METAL_SCALE_MAIL                     3       /* 13 */
#define SV_CHAIN_MAIL                           4       /* 14 */
#define SV_AUGMENTED_CHAIN_MAIL         6       /* 16 */
#define SV_DOUBLE_CHAIN_MAIL            7       /* 16 */
#define SV_BAR_CHAIN_MAIL                       8       /* 18 */
#define SV_METAL_BRIGANDINE_ARMOUR      9       /* 19 */
#define SV_PARTIAL_PLATE_ARMOUR         12      /* 22 */
#define SV_METAL_LAMELLAR_ARMOUR        13      /* 23 */
#define SV_FULL_PLATE_ARMOUR            15      /* 25 */
#define SV_RIBBED_PLATE_ARMOUR          18      /* 28 */
#define SV_MITHRIL_CHAIN_MAIL           20      /* 28+ */
#define SV_MITHRIL_PLATE_MAIL           25      /* 35+ */
#define SV_ADAMANTITE_PLATE_MAIL        30      /* 40+ */

/* The "sval" codes for TV_DRAG_ARMOR */
#define SV_DRAGON_BLACK                 1
#define SV_DRAGON_BLUE                  2
#define SV_DRAGON_WHITE                 3
#define SV_DRAGON_RED                   4
#define SV_DRAGON_GREEN                 5
#define SV_DRAGON_MULTIHUED             6
#define SV_DRAGON_SHINING               10
#define SV_DRAGON_LAW                   12
#define SV_DRAGON_BRONZE                14
#define SV_DRAGON_GOLD                  16
#define SV_DRAGON_CHAOS                 18
#define SV_DRAGON_BALANCE               20
#define SV_DRAGON_POWER                 30

/* The sval codes for TV_LITE */
#define SV_LITE_TORCH           0
#define SV_LITE_LANTERN         1
#define SV_LITE_BEATRICE        4
#define SV_LITE_SEEING          5
#define SV_LITE_INSIGHT         6
#define SV_LITE_ORB             7
#define SV_LITE_WHITE_BANNER    8
#define SV_LITE_BANNER          9

/* The "sval" codes for TV_AMULET */
#define SV_AMULET_DOOM                  0
#define SV_AMULET_TELEPORT              1
#define SV_AMULET_ADORNMENT             2
#define SV_AMULET_SLOW_DIGEST           3
#define SV_AMULET_RESIST_ACID           4
#define SV_AMULET_SEARCHING             5
#define SV_AMULET_BRILLIANCE            6
#define SV_AMULET_CHARISMA              7
#define SV_AMULET_THE_MAGI              8
#define SV_AMLUET_REFLECTION            9
#define SV_AMULET_PURITY                10
#define SV_AMULET_INQUISITION           11
#define SV_AMULET_DWARVES               12
#define SV_AMULET_NO_MAGIC              13
#define SV_AMULET_NO_TELE               14
#define SV_AMULET_RESISTANCE            15

/* The sval codes for TV_RING */
#define SV_RING_WOE                             0
#define SV_RING_AGGRAVATION             1
#define SV_RING_WEAKNESS                2
#define SV_RING_STUPIDITY               3
#define SV_RING_TELEPORTATION   4
/* xxx */
#define SV_RING_SLOW_DIGESTION  6
#define SV_RING_FEATHER_FALL    7
#define SV_RING_RESIST_FIRE             8
#define SV_RING_RESIST_COLD             9
#define SV_RING_SUSTAIN_BODY            10
#define SV_RING_SUSTAIN_MIND            11
#define SV_RING_COMBAT_LUST             12
#define SV_RING_SUSTAIN_DEX             13
#define SV_RING_SUSTAIN_CON             14
#define SV_RING_SUSTAIN_CHA             15
#define SV_RING_PROTECTION              16
#define SV_RING_ACID                    17
#define SV_RING_FLAMES                  18
#define SV_RING_ICE                             19
#define SV_RING_RESIST_POIS             20
#define SV_RING_FREE_ACTION             21
#define SV_RING_SEE_INVIS               22
#define SV_RING_SEARCHING               23
#define SV_RING_STR                             24
#define SV_RING_INT                             25
#define SV_RING_DEX                             26
#define SV_RING_CON                             27
#define SV_RING_ACCURACY                28
#define SV_RING_DAMAGE                  29
#define SV_RING_SLAYING                 30
#define SV_RING_SPEED                   31
#define SV_RING_MAGIC                 32
#define SV_RING_BAST                  33
#define SV_RING_ELEMFIRE                    34
#define SV_RING_ELEMICE                     35
#define SV_RING_ELEMSTORM                   36
#define SV_RING_ONERING                 37
#define SV_RING_RES_FEAR                38
#define SV_RING_RES_LD                  39
#define SV_RING_RES_NETHER              40
#define SV_RING_RES_NEXUS               41
#define SV_RING_RES_SOUND               42
#define SV_RING_RES_CONFUSION           43
#define SV_RING_RES_SHARDS              44
#define SV_RING_RES_DISENCHANT          45
#define SV_RING_RES_CHAOS               46
#define SV_RING_RES_BLINDNESS           47
#define SV_RING_LORDLY                  48
#define SV_RING_ATTACKS                 49

/* The "sval" codes for TV_STAFF */
#define SV_STAFF_DARKNESS               0
#define SV_STAFF_SLOWNESS               1
#define SV_STAFF_HASTE_MONSTERS 2
#define SV_STAFF_SUMMONING              3
#define SV_STAFF_TELEPORTATION  4
#define SV_STAFF_IDENTIFY               5
#define SV_STAFF_REMOVE_CURSE   6
#define SV_STAFF_STARLITE               7
#define SV_STAFF_LITE                   8
#define SV_STAFF_MAPPING                9
#define SV_STAFF_DETECT_GOLD    10
#define SV_STAFF_DETECT_ITEM    11
#define SV_STAFF_DETECT_TRAP    12
#define SV_STAFF_DETECT_DOOR    13
#define SV_STAFF_DETECT_INVIS   14
#define SV_STAFF_DETECT_EVIL    15
#define SV_STAFF_CURE_LIGHT             16
#define SV_STAFF_CURING                 17
#define SV_STAFF_HEALING                18
#define SV_STAFF_THE_MAGI               19
#define SV_STAFF_SLEEP_MONSTERS 20
#define SV_STAFF_SLOW_MONSTERS  21
#define SV_STAFF_SPEED                  22
#define SV_STAFF_PROBING                23
#define SV_STAFF_DISPEL_EVIL    24
#define SV_STAFF_POWER                  25
#define SV_STAFF_HOLINESS               26
#define SV_STAFF_GENOCIDE               27
#define SV_STAFF_EARTHQUAKES    28
#define SV_STAFF_DESTRUCTION    29


/* The "sval" codes for TV_WAND */
#define SV_WAND_HEAL_MONSTER    0
#define SV_WAND_HASTE_MONSTER   1
#define SV_WAND_CLONE_MONSTER   2
#define SV_WAND_TELEPORT_AWAY   3
#define SV_WAND_DISARMING               4
#define SV_WAND_TRAP_DOOR_DEST  5
#define SV_WAND_STONE_TO_MUD    6
#define SV_WAND_LITE                    7
#define SV_WAND_SLEEP_MONSTER   8
#define SV_WAND_SLOW_MONSTER    9
#define SV_WAND_CONFUSE_MONSTER 10
#define SV_WAND_FEAR_MONSTER    11
#define SV_WAND_DRAIN_LIFE              12
#define SV_WAND_POLYMORPH               13
#define SV_WAND_STINKING_CLOUD  14
#define SV_WAND_MAGIC_MISSILE   15
#define SV_WAND_ACID_BOLT               16
#define SV_WAND_CHARM_MONSTER           17
#define SV_WAND_FIRE_BOLT               18
#define SV_WAND_COLD_BOLT               19
#define SV_WAND_ACID_BALL               20
#define SV_WAND_ELEC_BALL               21
#define SV_WAND_FIRE_BALL               22
#define SV_WAND_COLD_BALL               23
#define SV_WAND_WONDER                  24
#define SV_WAND_ANNIHILATION    25
#define SV_WAND_DRAGON_FIRE             26
#define SV_WAND_DRAGON_COLD             27
#define SV_WAND_DRAGON_BREATH   28
#define SV_WAND_SHARD         29

/* The "sval" codes for TV_ROD */
#define SV_ROD_DETECT_TRAP              0
#define SV_ROD_DETECT_DOOR              1
#define SV_ROD_IDENTIFY                 2
#define SV_ROD_RECALL                   3
#define SV_ROD_ILLUMINATION             4
#define SV_ROD_MAPPING                  5
#define SV_ROD_DETECTION                6
#define SV_ROD_PROBING                  7
#define SV_ROD_CURING                   8
#define SV_ROD_HEALING                  9
#define SV_ROD_RESTORATION              10
#define SV_ROD_SPEED                    11
/* xxx (aimed) */
#define SV_ROD_TELEPORT_AWAY    13
#define SV_ROD_DISARMING                14
#define SV_ROD_LITE                             15
#define SV_ROD_SLEEP_MONSTER    16
#define SV_ROD_SLOW_MONSTER             17
#define SV_ROD_DRAIN_LIFE               18
#define SV_ROD_POLYMORPH                19
#define SV_ROD_ACID_BOLT                20
#define SV_ROD_ELEC_BOLT                21
#define SV_ROD_FIRE_BOLT                22
#define SV_ROD_COLD_BOLT                23
#define SV_ROD_ACID_BALL                24
#define SV_ROD_ELEC_BALL                25
#define SV_ROD_FIRE_BALL                26
#define SV_ROD_COLD_BALL                27
#define SV_ROD_HAVOC                    28


/* The "sval" codes for TV_SCROLL */

#define SV_SCROLL_DARKNESS                              0
#define SV_SCROLL_AGGRAVATE_MONSTER             1
#define SV_SCROLL_CURSE_ARMOR                   2
#define SV_SCROLL_CURSE_WEAPON                  3
#define SV_SCROLL_SUMMON_MONSTER                4
#define SV_SCROLL_SUMMON_UNDEAD                 5
/* xxx (summon?) */
#define SV_SCROLL_TRAP_CREATION                 7
#define SV_SCROLL_PHASE_DOOR                    8
#define SV_SCROLL_TELEPORT                              9
#define SV_SCROLL_TELEPORT_LEVEL                10
#define SV_SCROLL_WORD_OF_RECALL                11
#define SV_SCROLL_IDENTIFY                              12
#define SV_SCROLL_STAR_IDENTIFY                 13
#define SV_SCROLL_REMOVE_CURSE                  14
#define SV_SCROLL_STAR_REMOVE_CURSE             15
#define SV_SCROLL_ENCHANT_ARMOR                 16
#define SV_SCROLL_ENCHANT_WEAPON_TO_HIT 17
#define SV_SCROLL_ENCHANT_WEAPON_TO_DAM 18
/* xxx enchant missile? */
#define SV_SCROLL_STAR_ENCHANT_ARMOR    20
#define SV_SCROLL_STAR_ENCHANT_WEAPON   21
#define SV_SCROLL_RECHARGING                    22
/* xxx */
#define SV_SCROLL_LIGHT                                 24
#define SV_SCROLL_MAPPING                               25
#define SV_SCROLL_DETECT_GOLD                   26
#define SV_SCROLL_DETECT_ITEM                   27
#define SV_SCROLL_DETECT_TRAP                   28
#define SV_SCROLL_DETECT_DOOR                   29
#define SV_SCROLL_DETECT_INVIS                  30
/* xxx (detect evil?) */
#define SV_SCROLL_SATISFY_HUNGER                32
#define SV_SCROLL_BLESSING                              33
#define SV_SCROLL_HOLY_CHANT                    34
#define SV_SCROLL_HOLY_PRAYER                   35
#define SV_SCROLL_MONSTER_CONFUSION             36
#define SV_SCROLL_PROTECTION_FROM_EVIL  37
#define SV_SCROLL_RUNE_OF_PROTECTION    38
#define SV_SCROLL_TRAP_DOOR_DESTRUCTION 39
/* xxx */
#define SV_SCROLL_STAR_DESTRUCTION              41
#define SV_SCROLL_DISPEL_UNDEAD                 42
/* xxx */
#define SV_SCROLL_GENOCIDE                              44
#define SV_SCROLL_MASS_GENOCIDE                 45
#define SV_SCROLL_ACQUIREMENT                   46
#define SV_SCROLL_STAR_ACQUIREMENT              47
#define SV_SCROLL_FIRE                          48
#define SV_SCROLL_ICE                           49
#define SV_SCROLL_CHAOS                         50
#define SV_SCROLL_RUMOR                         51
#define SV_SCROLL_ARTIFACT                      52

/* The "sval" codes for TV_POTION */
#define SV_POTION_WATER                         0
#define SV_POTION_APPLE_JUICE           1
#define SV_POTION_SLIME_MOLD            2
/* xxx (fixed colour) */
#define SV_POTION_SLOWNESS                      4
#define SV_POTION_SALT_WATER            5
#define SV_POTION_POISON                        6
#define SV_POTION_BLINDNESS                     7
/* xxx */
#define SV_POTION_CONFUSION                     9
/* xxx */
#define SV_POTION_SLEEP                         11
/* xxx */
#define SV_POTION_LOSE_MEMORIES         13
/* xxx */
#define SV_POTION_RUINATION                     15
#define SV_POTION_DEC_STR                       16
#define SV_POTION_DEC_INT                       17
#define SV_POTION_DEC_WIS                       18
#define SV_POTION_DEC_DEX                       19
#define SV_POTION_DEC_CON                       20
#define SV_POTION_DEC_CHA                       21
#define SV_POTION_DETONATIONS           22
#define SV_POTION_IOCAINE                         23
#define SV_POTION_INFRAVISION           24
#define SV_POTION_DETECT_INVIS          25
#define SV_POTION_SLOW_POISON           26
#define SV_POTION_CURE_POISON           27
#define SV_POTION_BOLDNESS                      28
#define SV_POTION_SPEED                         29
#define SV_POTION_RESIST_HEAT           30
#define SV_POTION_RESIST_COLD           31
#define SV_POTION_HEROISM                       32
#define SV_POTION_BESERK_STRENGTH       33
#define SV_POTION_CURE_LIGHT            34
#define SV_POTION_CURE_SERIOUS          35
#define SV_POTION_CURE_CRITICAL         36
#define SV_POTION_HEALING                       37
#define SV_POTION_STAR_HEALING          38
#define SV_POTION_LIFE                          39
#define SV_POTION_RESTORE_MANA          40
#define SV_POTION_RESTORE_EXP           41
#define SV_POTION_RES_STR                       42
#define SV_POTION_RES_INT                       43
#define SV_POTION_RES_WIS                       44
#define SV_POTION_RES_DEX                       45
#define SV_POTION_RES_CON                       46
#define SV_POTION_RES_CHA                       47
#define SV_POTION_INC_STR                       48
#define SV_POTION_INC_INT                       49
#define SV_POTION_INC_WIS                       50
#define SV_POTION_INC_DEX                       51
#define SV_POTION_INC_CON                       52
#define SV_POTION_INC_CHA                       53
/* xxx */
#define SV_POTION_AUGMENTATION                  55
#define SV_POTION_ENLIGHTENMENT                 56
#define SV_POTION_STAR_ENLIGHTENMENT    57
#define SV_POTION_SELF_KNOWLEDGE                58
#define SV_POTION_EXPERIENCE                    59
#define SV_POTION_RESISTANCE                    60
#define SV_POTION_CURING                        61
#define SV_POTION_INVULNERABILITY               62
#define SV_POTION_NEW_LIFE                      63

/* "Sval" limit -- maximum amount of potions */
#define SV_POTION_MAX							64

/* The "sval" codes for TV_FOOD */
#define SV_FOOD_POISON                  0
#define SV_FOOD_THIRD_SIGHT               1
#define SV_FOOD_FRIGHT                2
#define SV_FOOD_CONFUSION               3
#define SV_FOOD_HALLUCINATION   4
#define SV_FOOD_PARALYSIS               5
#define SV_FOOD_WEAKNESS                6
#define SV_FOOD_SICKNESS                7
#define SV_FOOD_STUPIDITY               8
#define SV_FOOD_NAIVETY                 9
#define SV_FOOD_UNHEALTH                10
#define SV_FOOD_DISEASE                 11
#define SV_FOOD_CURE_POISON             12
#define SV_FOOD_CURE_BLINDNESS  13
#define SV_FOOD_CURE_PARANOIA   14
#define SV_FOOD_CURE_CONFUSION  15
#define SV_FOOD_CURE_SERIOUS    16
#define SV_FOOD_RESTORE_STR             17
#define SV_FOOD_RESTORE_CON             18
#define SV_FOOD_RESTORING               19
/* many missing mushrooms */
#define SV_FOOD_BISCUIT                 32
#define SV_FOOD_JERKY                   33
#define SV_FOOD_RATION                  35
#define SV_FOOD_SLIME_MOLD              36
#define SV_FOOD_AMBROSIA                37
#define SV_FOOD_PINT_OF_ALE             38
#define SV_FOOD_PINT_OF_WINE    39


/*
* Special "sval" limit -- first "normal" food
*/
#define SV_FOOD_MIN_FOOD        32

/*
* Special "sval" limit -- first "aimed" rod
*/
#define SV_ROD_MIN_DIRECTION    12

/*
* Special "sval" limit -- first "large" chest
*/
#define SV_CHEST_MIN_LARGE      4

/*
* Special "sval" limit -- first "good" magic/prayer book
*/
#define SV_BOOK_MIN_GOOD    2

/*
* Handedness Values for Weapons
*/

#define ONE_HANDED    1
#define TWO_HANDED   2
#define  HAND_AND_HALF   3

/*** General flag values ***/


/*
* Special cave grid flags
*/
#define CAVE_MARK       0x01    /* memorized feature */
#define CAVE_GLOW       0x02    /* self-illuminating */
#define CAVE_ICKY       0x04    /* part of a vault */
#define CAVE_ROOM       0x08    /* part of a room */
#define CAVE_LITE       0x10    /* lite flag  */
#define CAVE_VIEW       0x20    /* view flag */
#define CAVE_TEMP       0x40    /* temp flag */
#define CAVE_XTRA       0x80    /* misc flag */

/*
* Start Points for surface levels
*/

#define START_STAIRS 0  /* Player came up stairs */
#define START_WALK 1  /* Player walked here through wilderness */
#define START_RANDOM 2  /* Player WoR'ed here */
#define START_PATH 3 /* Player walked here through a path */

/*
* Bit flags for the "project()" function
*
*   JUMP: Jump directly to the target location (this is a hack)
*   BEAM: Work as a beam weapon (affect every grid passed through)
*   THRU: Continue "through" the target (used for "bolts"/"beams")
*   STOP: Stop as soon as we hit a monster (used for "bolts")
*   GRID: Affect each grid in the "blast area" in some way
*   ITEM: Affect each object in the "blast area" in some way
*   KILL: Affect each monster in the "blast area" in some way
*   HIDE: Hack -- disable "visual" feedback from projection
*/
#define PROJECT_JUMP    0x01
#define PROJECT_BEAM    0x02
#define PROJECT_THRU    0x04
#define PROJECT_STOP    0x08
#define PROJECT_GRID    0x10
#define PROJECT_ITEM    0x20
#define PROJECT_KILL    0x40
#define PROJECT_HIDE    0x80

/*
* Bit flags for the "enchant()" function
*/
#define ENCH_TOHIT   0x01
#define ENCH_TODAM   0x02
#define ENCH_TOAC    0x04

/*
* Bit flags for the "target_set" function XXX XXX XXX
*
*      KILL: Target monsters
*      LOOK: Describe grid fully
*      XTRA: Currently unused flag
*      GRID: Select from all grids
*/
#define TARGET_KILL             0x01
#define TARGET_LOOK             0x02
#define TARGET_XTRA             0x04
#define TARGET_GRID             0x08

/*
* Some bit-flags for the "smart" field
*/
#define SM_RES_ACID             0x00000001
#define SM_RES_ELEC             0x00000002
#define SM_RES_FIRE             0x00000004
#define SM_RES_COLD             0x00000008
#define SM_RES_POIS             0x00000010
#define SM_RES_NETH             0x00000020
#define SM_RES_LITE             0x00000040
#define SM_RES_DARK             0x00000080
#define SM_RES_FEAR             0x00000100
#define SM_RES_CONF             0x00000200
#define SM_RES_CHAOS			0x00000400
#define SM_RES_DISEN			0x00000800
#define SM_RES_BLIND			0x00001000
#define SM_RES_NEXUS			0x00002000
#define SM_RES_SOUND			0x00004000
#define SM_RES_SHARD			0x00008000
#define SM_OPP_ACID             0x00010000
#define SM_OPP_ELEC             0x00020000
#define SM_OPP_FIRE             0x00040000
#define SM_OPP_COLD             0x00080000
#define SM_OPP_POIS             0x00100000
#define SM_OPP_XXX1             0x00200000
#define SM_CLONED               0x00400000

#define SM_IMM_ACID             0x01000000
#define SM_IMM_ELEC             0x02000000
#define SM_IMM_FIRE             0x04000000
#define SM_IMM_COLD             0x08000000
#define SM_IMM_XXX5             0x10000000
#define SM_IMM_REFLECT          0x20000000
#define SM_IMM_FREE             0x40000000
#define SM_IMM_MANA             0x80000000

/*
 * Some bit-flags for the "ally" field
 * Ally_self means true neutral, like the giant in the ninth circel
 * 
 */

#define ALLY_NO					0
#define ALLY_LUCIFER		    1
#define ALLY_GOD				2
#define ALLY_RACE				4
#define ALLY_PLAYER				8
#define ALLY_SELF				16
#define ALLY_COMPANION			32

/*
* Bit flags for the "p_ptr->notice" variable
*/
#define PN_COMBINE      0x00000001L     /* Combine the pack */
#define PN_REORDER      0x00000002L     /* Reorder the pack */
/* xxx (many) */


/*
* Bit flags for the "p_ptr->update" variable
*/
#define PU_BONUS        0x00000001L     /* Calculate bonuses */
#define PU_TORCH        0x00000002L     /* Calculate torch radius */
/* xxx (many) */
#define PU_HP           0x00000010L     /* Calculate chp and mhp */
#define PU_MANA         0x00000020L     /* Calculate csp and msp */
#define PU_SPELLS       0x00000040L     /* Calculate spells */
/* xxx (many) */
/* xxx (many) */
#define PU_UN_VIEW      0x00010000L     /* Forget view */
#define PU_UN_LITE      0x00020000L     /* Forget lite */
/* xxx (many) */
#define PU_VIEW         0x00100000L     /* Update view */
#define PU_LITE         0x00200000L     /* Update lite */
/* xxx */
#define PU_MONSTERS     0x01000000L     /* Update monsters */
#define PU_DISTANCE     0x02000000L     /* Update distances */
/* xxx */
#define PU_FLOW         0x10000000L     /* Update flow */
/* xxx (many) */


/*
* Bit flags for the "p_ptr->redraw" variable
* Obsolete one:
#define PR_STATS                    0x00000010L      Display Stats 
#define PR_TIME                     0x00008000L      Display Time
#define PR_EQUIPPY                  0x00000400L      Display equippy chars
*/
#define PR_MISC                     0x00000001L     /* Display Race/Class */
#define PR_TITLE                    0x00000002L     /* Display Title */
#define PR_LEV                      0x00000004L     /* Display Level */
#define PR_EXP                      0x00000008L     /* Display Experience */
#define PR_ARMOR                    0x00000020L     /* Display Armor */
#define PR_HP                       0x00000040L     /* Display Hitpoints */
#define PR_MANA                     0x00000080L     /* Display Mana */
#define PR_GOLD                     0x00000100L     /* Display Gold */
#define PR_DEPTH                    0x00000200L     /* Display Depth */
#define PR_HEALTH                   0x00000800L     /* Display Health Bar */
#define PR_CUT                      0x00001000L     /* Display Extra (Cut) */
#define PR_STUN                     0x00002000L     /* Display Extra (Stun) */
#define PR_HUNGER                   0x00004000L     /* Display Extra (Hunger) */
#define PR_BLIND                    0x00010000L     /* Display Extra (Blind) */
#define PR_CONFUSED                 0x00020000L     /* Display Extra (Confused) */
#define PR_AFRAID                   0x00040000L     /* Display Extra (Afraid) */
#define PR_POISONED                 0x00080000L     /* Display Extra (Poisoned) */
#define PR_STATE                    0x00100000L     /* Display Extra (State) */
#define PR_SPEED                    0x00200000L     /* Display Extra (Speed) */
#define PR_STUDY                    0x00400000L     /* Display Extra (Study) */
/* xxx */
#define PR_EXTRA                    0x01000000L     /* Display Extra Info */
#define PR_BASIC                    0x02000000L     /* Display Basic Info */
#define PR_MAP                      0x04000000L     /* Display Map */
#define PR_WIPE                     0x08000000L     /* Hack -- Total Redraw */
/* xxx */
/* xxx */
/* xxx */
/* xxx */

/*
* Bit flags for the "p_ptr->window" variable (etc)
* Update PW_FLAG_COUNT when you need more window bit flags!!
*/
#define PW_INVEN                    0x00000001L     /* 1     Display inven/equip */
#define PW_EQUIP                    0x00000002L     /* 2     Display equip/inven */
#define PW_SPELL                    0x00000004L     /* 4     Display spell list */
#define PW_PLAYER                   0x00000008L     /* 8     Display character */
/* xxx */                                           /* 16    Display character */
/* xxx */                                           /* 32    Display character */
#define PW_MESSAGE                  0x00000040L     /* 64    Display messages */
#define PW_OVERHEAD                 0x00000080L     /* 128   Display overhead view */
#define PW_MONSTER                  0x00000100L     /* 256   Display monster recall */
#define PW_OBJECT                   0x00000200L     /* 512   Display object recall */
#define PW_VISIBLE                  0x00000400L     /* 1024  Show visible monster list */
#define PW_SNAPSHOT                 0x00000800L     /* 2048  Display snap-shot */
#define PW_VISIBLE_ITEMS            0x00001000L     /* 4096  visible monster list */
/* xxx */                                           /* 8192  Display character */
#define PW_BORG_1                   0x00004000L     /* 16384 Display borg messages */
#define PW_BORG_2                   0x00008000L     /* 32768 Display borg status */

/* Update this when you need more window bit flags!! */
#define PW_FLAG_COUNT 16

/*** General index values ***/


/*
* Legal restrictions for "summon_specific()"
*/
#define FILTER_ANT                  11
#define FILTER_SPIDER               12
#define FILTER_HOUND                13
#define FILTER_HYDRA                14
#define FILTER_DEVIL                15
#define FILTER_DEMON                16
#define FILTER_UNDEAD               17
#define FILTER_DRAGON               18
#define FILTER_HI_UNDEAD            21
#define FILTER_HI_DRAGON            22
#define FILTER_FALLEN_ANGELS        31
#define FILTER_UNIQUE               32
#define FILTER_BIZARRE1             33
#define FILTER_BIZARRE2             34
#define FILTER_BIZARRE3             35
#define FILTER_BIZARRE4             36
#define FILTER_BIZARRE5             37
#define FILTER_BIZARRE6             38
#define FILTER_REAVER               39
#define FILTER_KIN                  40
#define FILTER_ANIMAL               42
#define FILTER_ANIMAL_RANGER        43
#define FILTER_HI_UNDEAD_NO_UNIQUES 44
#define FILTER_HI_DRAGON_NO_UNIQUES 45
#define FILTER_NO_UNIQUES           46
#define FILTER_PHANTOM              47
#define FILTER_ELEMENTAL            48
#define FILTER_HUMAN			    51
#define FILTER_SKULLS               53
#define FILTER_SPIRITS              55

/*
* Spell types used by project(), and related functions.
*/
#define GF_ELEC                     1
#define GF_POIS                     2
#define GF_ACID                     3
#define GF_COLD                     4
#define GF_FIRE                     5
#define GF_MISSILE                  10
#define GF_ARROW                    11
#define GF_PLASMA                   12
/* Replaced with GF_HOLY_FIRE and GF_HELL_FIRE */
/* #define GF_HOLY_ORB     13 */
#define GF_WATER                    14
#define GF_LITE                     15
#define GF_DARK                     16
#define GF_LITE_WEAK                17
#define GF_DARK_WEAK                18
#define GF_SHARDS                   20
#define GF_SOUND                    21
#define GF_CONFUSION                22
#define GF_FORCE                    23
#define GF_INERTIA                  24
#define GF_MANA                     26
#define GF_METEOR                   27
#define GF_ICE                      28
#define GF_CHAOS                    30
#define GF_NETHER                   31
#define GF_DISENCHANT               32
#define GF_NEXUS                    33
#define GF_TIME                     34
#define GF_GRAVITY                  35
#define GF_KILL_WALL                40
#define GF_KILL_DOOR                41
#define GF_KILL_TRAP                42
#define GF_MAKE_WALL                45
#define GF_MAKE_DOOR                46
#define GF_MAKE_TRAP                47
#define GF_OLD_CLONE                51
#define GF_OLD_POLY                 52
#define GF_OLD_HEAL                 53
#define GF_OLD_SPEED                54
#define GF_OLD_SLOW                 55
#define GF_OLD_CONF                 56
#define GF_OLD_SLEEP                57
#define GF_OLD_DRAIN                58
#define GF_AWAY_UNDEAD              61
#define GF_AWAY_EVIL                62
#define GF_AWAY_ALL                 63
#define GF_TURN_UNDEAD              64
#define GF_TURN_EVIL                65
#define GF_TURN_ALL                 66
#define GF_DISP_UNDEAD              67
#define GF_DISP_EVIL                68
#define GF_DISP_ALL                 69
#define GF_DISP_DEMON               70
#define GF_DISP_LIVING              71
#define GF_SHARD                    72
#define GF_HELLSLIME                73
#define GF_MAKE_GLYPH               74
#define GF_STASIS                   75
#define GF_STONE_WALL               76
#define GF_DEATH_RAY                77
#define GF_STUN                     78
#define GF_HOLY_FIRE                79
#define GF_HELL_FIRE                80
#define GF_DISINTEGRATE             81
#define GF_CHARM                    82
#define GF_CONTROL_UNDEAD           83
#define GF_CONTROL_ANIMAL           84
#define GF_PSI                      85
#define GF_PSI_DRAIN                86
#define GF_TELEKINESIS              87
#define GF_JAM_DOOR                 88
#define GF_DOMINATION               89
#define GF_DISP_GOOD                90
#define GF_MAGEBOLT                 91
#define GF_HECATE                   92
#define GF_DISP_FALLEN_ANGEL        93
#define GF_BLASTED_TOWER            94
#define GF_DISP_DEVIL               95
#define GF_EXP                      96

/*
* Distance at which pets follow the player
*/
#define FOLLOW_DISTANCE             4

/*
* Some things which induce learning
*/
#define DRS_ACID                    1
#define DRS_ELEC                    2
#define DRS_FIRE                    3
#define DRS_COLD                    4
#define DRS_POIS                    5
#define DRS_NETH                    6
#define DRS_LITE                    7
#define DRS_DARK                    8
#define DRS_FEAR                    9
#define DRS_CONF                    10
#define DRS_CHAOS                   11
#define DRS_DISEN                   12
#define DRS_BLIND                   13
#define DRS_NEXUS                   14
#define DRS_SOUND                   15
#define DRS_SHARD                   16
#define DRS_FREE                    30
#define DRS_MANA                    31
#define DRS_REFLECT                 32



/*
* Hack -- first "normal" artefact in the artefact list.  All of
* the artefacts with indexes from 1 to 15 are "special" (lights,
* rings, amulets), and the ones from 16 to 127 are "normal".
*/
#define ART_MIN_NORMAL              16


/*
* Hack -- special "xtra" object powers
*/

/* Sustain one stat */
#define EGO_XTRA_SUSTAIN            1

/* High resist */
#define EGO_XTRA_POWER              2

/* Special ability */
#define EGO_XTRA_ABILITY            3

/*** Object flag values ***/


/*
* Chest trap flags (see "tables.c")
*/
#define CHEST_LOSE_STR              0x01
#define CHEST_LOSE_CON              0x02
#define CHEST_POISON                0x04
#define CHEST_PARALYZE              0x08
#define CHEST_EXPLODE               0x10
#define CHEST_SUMMON                0x20



/*
* Special Object Flags
*/
#define IDENT_SENSE                 0x01    /* Item has been "sensed" */
#define IDENT_FIXED                 0x02    /* Item has been "haggled" */
#define IDENT_EMPTY                 0x04    /* Item charges are known */
#define IDENT_KNOWN                 0x08    /* Item abilities are known */
#define IDENT_STOREB                0x10    /* Item is storebought !!!! */
#define IDENT_MENTAL                0x20    /* Item information is known */
#define IDENT_CURSED                0x40    /* Item is temporarily cursed */
#define IDENT_BROKEN                0x80    /* Item is permanently worthless */



/*
* Special Monster Flags (all temporary)
*/
#define MFLAG_VIEW                  0x01    /* Monster is in line of sight */
/* xxx */
#define MFLAG_BORN                  0x10    /* Monster is still being born */
#define MFLAG_NICE                  0x20    /* Monster is still being nice */
#define MFLAG_SHOW                  0x40    /* Monster is recently memorized */
#define MFLAG_MARK				    0x80    /* Monster is currently memorized */



/*
* As of 2.7.8, the "object flags" are valid for all objects, and as
* of 2.7.9, these flags are not actually stored with the object.
*
* Note that "flags1" contains all flags dependant on "pval" (including
* stat bonuses, but NOT stat sustainers), plus all "extra attack damage"
* flags (SLAY_XXX and BRAND_XXX).
*
* Note that "flags2" contains all "resistances" (including "Stat Sustainers",
* actual immunities, and resistances).  Note that "Hold Life" is really an
* "immunity" to ExpLoss, and "Free Action" is "immunity to paralysis".
*
* Note that "flags3" contains everything else -- including the three "CURSED"
* flags, and the "BLESSED" flag, several "item display" parameters, some new
* flags for powerful Bows, and flags which affect the player in a "general"
* way (LITE, TELEPATHY, SEE_INVIS, SLOW_DIGEST, REGEN, FEATHER), including
* all the "general" curses (TELEPORT, AGGRAVATE, EXP_DRAIN).  It also has
* four new flags called "ITEM_IGNORE_XXX" which lets an item specify that
* it can not be affected by various forms of destruction.  This is NOT as
* powerful as actually granting resistance/immunity to the wearer.
*/

#define TR1_STR                     0x00000001L     /* STR += "pval" */
#define TR1_INT                     0x00000002L     /* INT += "pval" */
#define TR1_WIS                     0x00000004L     /* WIS += "pval" */
#define TR1_DEX                     0x00000008L     /* DEX += "pval" */
#define TR1_CON                     0x00000010L     /* CON += "pval" */
#define TR1_CHA                     0x00000020L     /* CHA += "pval" */
#define TR1_XXX1                    0x00000040L     /* Later */
#define TR1_XXX2                    0x00000080L     /* Later */
#define TR1_STEALTH                 0x00000100L     /* Stealth += "pval" */
#define TR1_SEARCH                  0x00000200L     /* Search += "pval" */
#define TR1_INFRA                   0x00000400L     /* Infra += "pval" */
#define TR1_TUNNEL                  0x00000800L     /* Tunnel += "pval" */
#define TR1_SPEED                   0x00001000L     /* Speed += "pval" */
#define TR1_BLOWS                   0x00002000L     /* Blows += "pval" */
#define TR1_CHAOTIC                 0x00004000L
#define TR1_VAMPIRIC                0x00008000L
#define TR1_SLAY_ANIMAL             0x00010000L
#define TR1_SLAY_EVIL               0x00020000L
#define TR1_SLAY_UNDEAD             0x00040000L
#define TR1_SLAY_DEMON              0x00080000L
#define TR1_SLAY_ANGEL              0x00100000L
#define TR1_KILL_ANGEL              0x00200000L
#define TR1_SLAY_GIANT              0x00400000L
#define TR1_SLAY_DRAGON             0x00800000L
#define TR1_KILL_DRAGON             0x01000000L     /* Execute Dragon */
#define TR1_VORPAL                  0x02000000L     /* Later */
#define TR1_IMPACT                  0x04000000L     /* Cause Earthquakes */
#define TR1_BRAND_POIS              0x08000000L
#define TR1_BRAND_ACID              0x10000000L
#define TR1_BRAND_ELEC              0x20000000L
#define TR1_BRAND_FIRE              0x40000000L
#define TR1_BRAND_COLD              0x80000000L

#define TR2_SUST_STR                0x00000001L
#define TR2_SUST_INT                0x00000002L
#define TR2_SUST_WIS                0x00000004L
#define TR2_SUST_DEX                0x00000008L
#define TR2_SUST_CON                0x00000010L
#define TR2_SUST_CHA                0x00000020L
#define TR2_XXX1                    0x00000040L     /* Later */
#define TR2_XXX2                    0x00000080L     /* Later */
#define TR2_IM_ACID                 0x00000100L
#define TR2_IM_ELEC                 0x00000200L
#define TR2_IM_FIRE                 0x00000400L
#define TR2_IM_COLD                 0x00000800L
#define TR2_XXX3                    0x00001000L     /* Later */
#define TR2_REFLECT                 0x00002000L     /* Reflect 'bolts' */
#define TR2_FREE_ACT                0x00004000L     /* Free Action */
#define TR2_HOLD_LIFE               0x00008000L     /* Hold Life */
#define TR2_RES_ACID                0x00010000L
#define TR2_RES_ELEC                0x00020000L
#define TR2_RES_FIRE                0x00040000L
#define TR2_RES_COLD                0x00080000L
#define TR2_RES_POIS                0x00100000L
#define TR2_RES_FEAR                0x00200000L
#define TR2_RES_LITE                0x00400000L
#define TR2_RES_DARK                0x00800000L
#define TR2_RES_BLIND               0x01000000L
#define TR2_RES_CONF                0x02000000L
#define TR2_RES_SOUND               0x04000000L
#define TR2_RES_SHARDS              0x08000000L
#define TR2_RES_NETHER              0x10000000L
#define TR2_RES_NEXUS               0x20000000L
#define TR2_RES_CHAOS               0x40000000L
#define TR2_RES_DISEN               0x80000000L


#define TR3_SH_FIRE					0x00000001L     /* Immolation (Fire) */
#define TR3_SH_ELEC					0x00000002L     /* Electric Sheath */
#define TR3_XP   					0x00000004L     /* Sentient Weapon */
#define TR3_XXX4                    0x00000008L     /* Later */
#define TR3_NO_TELE                 0x00000010L     /* Anti-teleportation */
#define TR3_NO_MAGIC                0x00000020L     /* Anti-magic */
#define TR3_WRAITH                  0x00000040L     /* Wraithform */
#define TR3_TY_CURSE                0x00000080L     /* The Ancient Curse */
#define TR3_EASY_KNOW               0x00000100L     /* Aware -> Known */
#define TR3_HIDE_TYPE               0x00000200L     /* Hide "pval" description */
#define TR3_SHOW_MODS               0x00000400L     /* Always show Tohit/Todam */
#define TR3_INSTA_ART               0x00000800L     /* Item must be an artefact */
#define TR3_FEATHER                 0x00001000L     /* Feather Falling */
#define TR3_LITE                    0x00002000L     /* Permanent Light */
#define TR3_SEE_INVIS               0x00004000L     /* See Invisible */
#define TR3_TELEPATHY               0x00008000L     /* Telepathy */
#define TR3_SLOW_DIGEST             0x00010000L     /* Item slows down digestion */
#define TR3_REGEN                   0x00020000L     /* Item induces regeneration */
#define TR3_XTRA_MIGHT              0x00040000L     /* Bows get extra multiplier */
#define TR3_XTRA_SHOTS              0x00080000L     /* Bows get extra shots */
#define TR3_IGNORE_ACID             0x00100000L     /* Item ignores Acid Damage */
#define TR3_IGNORE_ELEC             0x00200000L     /* Item ignores Elec Damage */
#define TR3_IGNORE_FIRE             0x00400000L     /* Item ignores Fire Damage */
#define TR3_IGNORE_COLD             0x00800000L     /* Item ignores Cold Damage */
#define TR3_ACTIVATE                0x01000000L     /* Item can be activated */
#define TR3_DRAIN_EXP               0x02000000L     /* Item drains Experience */
#define TR3_TELEPORT                0x04000000L     /* Item teleports player */
#define TR3_AGGRAVATE               0x08000000L     /* Item aggravates monsters */
#define TR3_BLESSED                 0x10000000L     /* Item is Blessed */
#define TR3_CURSED                  0x20000000L     /* Item is Cursed */
#define TR3_HEAVY_CURSE             0x40000000L     /* Item is Heavily Cursed */
#define TR3_PERMA_CURSE             0x80000000L     /* Item is Perma Cursed */

/*
* Hack -- flag set 1 -- mask for "pval-dependant" flags.
* Note that all "pval" dependant flags must be in "flags1".
*/
#define TR1_PVAL_MASK   \
	(TR1_STR | TR1_INT | TR1_WIS | TR1_DEX | \
	TR1_CON | TR1_CHA | \
	TR1_STEALTH | TR1_SEARCH | TR1_INFRA | TR1_TUNNEL | \
	TR1_SPEED | TR1_BLOWS )



/*** Monster blow constants ***/


/*
* New monster blow methods
*/
#define RBM_HIT                     1
#define RBM_TOUCH                   2
#define RBM_PUNCH                   3
#define RBM_KICK                    4
#define RBM_CLAW                    5
#define RBM_BITE                    6
#define RBM_STING                   7
#define RBM_XXX1                    8
#define RBM_BUTT                    9
#define RBM_CRUSH                   10
#define RBM_ENGULF                  11
#define RBM_CHARGE                  12 /* TY */
#define RBM_CRAWL                   13
#define RBM_DROOL                   14
#define RBM_SPIT                    15
#define RBM_XXX3                    16
#define RBM_GAZE                    17
#define RBM_WAIL                    18
#define RBM_SPORE                   19
#define RBM_WORSHIP                 20
#define RBM_BEG                     21
#define RBM_INSULT                  22
#define RBM_MOAN                    23
#define RBM_SHOW                    24 /* TY */


/*
* New monster blow effects
*/
#define RBE_HURT                    1
#define RBE_POISON                  2
#define RBE_UN_BONUS                3
#define RBE_UN_POWER                4
#define RBE_EAT_GOLD                5
#define RBE_EAT_ITEM                6
#define RBE_EAT_FOOD                7
#define RBE_EAT_LITE                8
#define RBE_ACID                    9
#define RBE_ELEC                    10
#define RBE_FIRE                    11
#define RBE_COLD                    12
#define RBE_BLIND                   13
#define RBE_CONFUSE                 14
#define RBE_TERRIFY                 15
#define RBE_PARALYZE                16
#define RBE_LOSE_STR                17
#define RBE_LOSE_INT                18
#define RBE_LOSE_WIS                19
#define RBE_LOSE_DEX                20
#define RBE_LOSE_CON                21
#define RBE_LOSE_CHA                22
#define RBE_LOSE_ALL                23
#define RBE_SHATTER                 24
#define RBE_EXP_10                  25
#define RBE_EXP_20                  26
#define RBE_EXP_40                  27
#define RBE_EXP_80                  28

/*** Monster flag values (hard-coded) ***/

/*
* New monster race bit flags
*/
#define RF1_UNIQUE                  0x00000001      /* Unique Monster */
#define RF1_GUARDIAN                0x00000002      /* Level Guardian */
#define RF1_MALE                    0x00000004      /* Male gender */
#define RF1_FEMALE                  0x00000008      /* Female gender */
#define RF1_CHAR_CLEAR              0x00000010      /* Absorbs symbol */
#define RF1_CHAR_MULTI              0x00000020      /* Changes symbol */
#define RF1_ATTR_CLEAR              0x00000040      /* Absorbs colour */
#define RF1_ATTR_MULTI              0x00000080      /* Changes colour */
#define RF1_ALWAYS_GUARD            0x00000100      /* Start at "correct" depth */
#define RF1_FORCE_MAXHP             0x00000200      /* Start with max hitpoints */
#define RF1_FORCE_SLEEP             0x00000400      /* Start out sleeping */
#define RF1_FORCE_EXTRA             0x00000800      /* Start out something */
#define RF1_FRIEND                  0x00001000      /* Arrive with a friend */
#define RF1_FRIENDS                 0x00002000      /* Arrive with some friends */
#define RF1_ESCORT                  0x00004000      /* Arrive with an escort */
#define RF1_ESCORTS                 0x00008000      /* Arrive with some escorts */
#define RF1_NEVER_BLOW              0x00010000      /* Never make physical blow */
#define RF1_NEVER_MOVE              0x00020000      /* Never make physical move */
#define RF1_RAND_25                 0x00040000      /* Moves randomly (25%) */
#define RF1_RAND_50                 0x00080000      /* Moves randomly (50%) */
#define RF1_ONLY_GOLD               0x00100000      /* Drop only gold */
#define RF1_ONLY_ITEM               0x00200000      /* Drop only items */
#define RF1_DROP_60                 0x00400000      /* Drop an item/gold (60%) */
#define RF1_DROP_90                 0x00800000      /* Drop an item/gold (90%) */
#define RF1_DROP_1D2                0x01000000      /* Drop 1d2 items/gold */
#define RF1_DROP_2D2                0x02000000      /* Drop 2d2 items/gold */
#define RF1_DROP_3D2                0x04000000      /* Drop 3d2 items/gold */
#define RF1_DROP_4D2                0x08000000      /* Drop 4d2 items/gold */
#define RF1_DROP_GOOD               0x10000000      /* Drop good items */
#define RF1_DROP_GREAT              0x20000000      /* Drop great items */
#define RF1_DROP_USEFUL             0x40000000      /* Drop "useful" items */
#define RF1_DROP_CHOSEN             0x80000000      /* Drop "chosen" items */

/*
* New monster race bit flags
*/
#define RF2_STUPID                  0x00000001      /* Monster is stupid */
#define RF2_SMART                   0x00000002      /* Monster is smart */
#define RF2_CAN_SPEAK               0x00000004  /* TY: can speak */
#define RF2_REFLECTING              0x00000008      /* Reflects bolts */
#define RF2_INVISIBLE               0x00000010      /* Monster avoids vision */
#define RF2_COLD_BLOOD              0x00000020      /* Monster avoids infra */
#define RF2_EMPTY_MIND              0x00000040      /* Monster avoids telepathy */
#define RF2_WEIRD_MIND              0x00000080      /* Monster avoids telepathy? */
#define RF2_MULTIPLY                0x00000100      /* Monster reproduces */
#define RF2_REGENERATE              0x00000200      /* Monster regenerates */
#define RF2_SHAPECHANGER            0x00000400  /* TY: shapechanger */
#define RF2_ATTR_ANY                0x00000800  /* TY: Attr_any */
#define RF2_POWERFUL                0x00001000      /* Monster has strong breath */
#define RF2_ELDRITCH_HORROR         0x00002000      /* Sanity-blasting horror    */
#define RF2_AURA_FIRE               0x00004000      /* Burns in melee */
#define RF2_AURA_ELEC               0x00008000      /* Shocks in melee */
#define RF2_OPEN_DOOR               0x00010000      /* Monster can open doors */
#define RF2_BASH_DOOR               0x00020000      /* Monster can bash doors */
#define RF2_PASS_WALL               0x00040000      /* Monster can pass walls */
#define RF2_KILL_WALL               0x00080000      /* Monster can destroy walls */
#define RF2_MOVE_BODY               0x00100000      /* Monster can move monsters */
#define RF2_KILL_BODY               0x00200000      /* Monster can kill monsters */
#define RF2_TAKE_ITEM               0x00400000      /* Monster can pick up items */
#define RF2_KILL_ITEM               0x00800000      /* Monster can crush items */
#define RF2_BRAIN_1                 0x01000000
#define RF2_BRAIN_2                 0x02000000
#define RF2_BRAIN_3                 0x04000000
#define RF2_BRAIN_4                 0x08000000
#define RF2_BRAIN_5                 0x10000000
#define RF2_BRAIN_6                 0x20000000
#define RF2_BRAIN_7                 0x40000000
#define RF2_BRAIN_8                 0x80000000

/*
* New monster race bit flags
*/
#define RF3_ORC                     0x00000001      /* Orc */
#define RF3_TROLL                   0x00000002      /* Troll */
#define RF3_GIANT                   0x00000004      /* Giant */
#define RF3_DRAGON                  0x00000008      /* Dragon */
#define RF3_DEMON                   0x00000010      /* Demon */
#define RF3_UNDEAD                  0x00000020      /* Undead */
#define RF3_EVIL                    0x00000040      /* Evil */
#define RF3_ANIMAL                  0x00000080      /* Animal */
#define RF3_FALLEN_ANGEL            0x00000100  /* TY: fallen angel */
#define RF3_GOOD                    0x00000200      /* Good */
#define RF3_PLAYER_GHOST            0x00000400      /* Monster is a player ghost */
#define RF3_NONLIVING               0x00000800  /* TY: Non-Living (?) */
#define RF3_HURT_LITE               0x00001000      /* Hurt by lite */
#define RF3_HURT_ROCK               0x00002000      /* Hurt by rock remover */
#define RF3_HURT_FIRE               0x00004000      /* Hurt badly by fire */
#define RF3_HURT_COLD               0x00008000      /* Hurt badly by cold */
#define RF3_IM_ACID                 0x00010000      /* Resist acid a lot */
#define RF3_IM_ELEC                 0x00020000      /* Resist elec a lot */
#define RF3_IM_FIRE                 0x00040000      /* Resist fire a lot */
#define RF3_IM_COLD                 0x00080000      /* Resist cold a lot */
#define RF3_IM_POIS                 0x00100000      /* Resist poison a lot */
#define RF3_RES_TELE                0x00200000      /* Resist teleportation */
#define RF3_RES_NETH                0x00400000      /* Resist nether a lot */
#define RF3_RES_WATE                0x00800000      /* Resist water */
#define RF3_RES_PLAS                0x01000000      /* Resist plasma */
#define RF3_RES_NEXU                0x02000000      /* Resist nexus */
#define RF3_RES_DISE                0x04000000      /* Resist disenchantment */
#define RF3_DEVIL                   0x08000000      /* devil */
#define RF3_NO_FEAR                 0x10000000      /* Cannot be scared */
#define RF3_NO_STUN                 0x20000000      /* Cannot be stunned */
#define RF3_NO_CONF                 0x40000000      /* Cannot be confused */
#define RF3_NO_SLEEP                0x80000000      /* Cannot be slept */

/*
* New monster race bit flags
*/
#define RF4_SHRIEK                  0x00000001      /* Shriek for help */
#define RF4_CUSTOM                    0x00000002      /* (?) */
#define RF4_XXX3                    0x00000004      /* (?) */
#define RF4_SHARD                   0x00000008   /* Fire shard balls */
#define RF4_ARROW_1                 0x00000010      /* Fire an arrow (light) */
#define RF4_ARROW_2                 0x00000020      /* Fire an arrow (heavy) */
#define RF4_ARROW_3                 0x00000040      /* Fire missiles (light) */
#define RF4_ARROW_4                 0x00000080      /* Fire missiles (heavy) */
#define RF4_BR_ACID                 0x00000100      /* Breathe Acid */
#define RF4_BR_ELEC                 0x00000200      /* Breathe Elec */
#define RF4_BR_FIRE                 0x00000400      /* Breathe Fire */
#define RF4_BR_COLD                 0x00000800      /* Breathe Cold */
#define RF4_BR_POIS                 0x00001000      /* Breathe Poison */
#define RF4_BR_NETH                 0x00002000      /* Breathe Nether */
#define RF4_BR_LITE                 0x00004000      /* Breathe Lite */
#define RF4_BR_DARK                 0x00008000      /* Breathe Dark */
#define RF4_BR_CONF                 0x00010000      /* Breathe Confusion */
#define RF4_BR_SOUN                 0x00020000      /* Breathe Sound */
#define RF4_BR_CHAO                 0x00040000      /* Breathe Primal Chaos */
#define RF4_BR_DISE                 0x00080000      /* Breathe Disenchant */
#define RF4_BR_NEXU                 0x00100000      /* Breathe Nexus */
#define RF4_BR_TIME                 0x00200000      /* Breathe Time */
#define RF4_BR_INER                 0x00400000      /* Breathe Inertia */
#define RF4_BR_GRAV                 0x00800000      /* Breathe Gravity */
#define RF4_BR_SHAR                 0x01000000      /* Breathe Shards */
#define RF4_BR_PLAS                 0x02000000      /* Breathe Plasma */
#define RF4_BR_WALL                 0x04000000      /* Breathe Force */
#define RF4_BR_MANA                 0x08000000      /* Breathe Mana */
#define RF4_BA_SLIM                 0x10000000  /* TY: Hell slime */
#define RF4_BR_SLIM                 0x20000000  /* TY: Toxic Breath */
#define RF4_BA_CHAO                 0x40000000  /* TY: Primal Chaos Ball */
#define RF4_BR_DISI                 0x80000000 /* Breathe Disintegration */

/*
* New monster race bit flags
*/
#define RF5_BA_ACID                 0x00000001      /* Acid Ball */
#define RF5_BA_ELEC                 0x00000002      /* Elec Ball */
#define RF5_BA_FIRE                 0x00000004      /* Fire Ball */
#define RF5_BA_COLD                 0x00000008      /* Cold Ball */
#define RF5_BA_POIS                 0x00000010      /* Poison Ball */
#define RF5_BA_NETH                 0x00000020      /* Nether Ball */
#define RF5_BA_WATE                 0x00000040      /* Water Ball */
#define RF5_BA_MANA                 0x00000080      /* Mana Storm */
#define RF5_BA_DARK                 0x00000100      /* Darkness Storm */
#define RF5_DRAIN_MANA              0x00000200      /* Drain Mana */
#define RF5_MIND_BLAST              0x00000400      /* Blast Mind */
#define RF5_BRAIN_SMASH             0x00000800      /* Smash Brain */
#define RF5_CAUSE_1                 0x00001000      /* Cause Light Wound */
#define RF5_CAUSE_2                 0x00002000      /* Cause Serious Wound */
#define RF5_CAUSE_3                 0x00004000      /* Cause Critical Wound */
#define RF5_CAUSE_4                 0x00008000      /* Cause Mortal Wound */
#define RF5_BO_ACID                 0x00010000      /* Acid Bolt */
#define RF5_BO_ELEC                 0x00020000      /* Elec Bolt (unused) */
#define RF5_BO_FIRE                 0x00040000      /* Fire Bolt */
#define RF5_BO_COLD                 0x00080000      /* Cold Bolt */
#define RF5_BO_POIS                 0x00100000      /* Poison Bolt (unused) */
#define RF5_BO_NETH                 0x00200000      /* Nether Bolt */
#define RF5_BO_WATE                 0x00400000      /* Water Bolt */
#define RF5_BO_MANA                 0x00800000      /* Mana Bolt */
#define RF5_BO_PLAS                 0x01000000      /* Plasma Bolt */
#define RF5_BO_ICEE                 0x02000000      /* Ice Bolt */
#define RF5_MISSILE                 0x04000000      /* Magic Missile */
#define RF5_SCARE                   0x08000000      /* Frighten Player */
#define RF5_BLIND                   0x10000000      /* Blind Player */
#define RF5_CONF                    0x20000000      /* Confuse Player */
#define RF5_SLOW                    0x40000000      /* Slow Player */
#define RF5_HOLD                    0x80000000      /* Paralyze Player */

/*
* New monster race bit flags
*/
#define RF6_HASTE                   0x00000001      /* Speed self */
#define RF6_MARK_CAIN             0x00000002      /* mark of Cain */
#define RF6_HEAL                    0x00000004      /* Heal self */
#define RF6_XXX2                    0x00000008      /* Heal a lot (?) */
#define RF6_BLINK                   0x00000010      /* Teleport Short */
#define RF6_TPORT                   0x00000020      /* Teleport Long */
#define RF6_XXX3                    0x00000040      /* Move to Player (?) */
#define RF6_XXX4                    0x00000080      /* Move to Monster (?) */
#define RF6_TELE_TO                 0x00000100      /* Move player to monster */
#define RF6_TELE_AWAY               0x00000200      /* Move player far away */
#define RF6_TELE_LEVEL              0x00000400      /* Move player vertically */
#define RF6_XXX5                    0x00000800      /* Move player (?) */
#define RF6_DARKNESS                0x00001000      /* Create Darkness */
#define RF6_TRAPS                   0x00002000      /* Create Traps */
#define RF6_FORGET                  0x00004000      /* Cause amnesia */
#define RF6_XXX6                    0x00008000      /* ??? */
#define RF6_S_KIN                   0x00010000      /* Summon "kin" */
#define RF6_S_REAVER                0x00020000      /* Summon Black Reavers! */
#define RF6_S_MONSTER               0x00040000      /* Summon Monster */
#define RF6_S_MONSTERS              0x00080000      /* Summon Monsters */
#define RF6_S_ANT                   0x00100000      /* Summon Ants */
#define RF6_S_SPIDER                0x00200000      /* Summon Spiders */
#define RF6_S_HOUND                 0x00400000      /* Summon Hounds */
#define RF6_S_HYDRA                 0x00800000      /* Summon Hydras */
#define RF6_S_DEVIL                 0x01000000      /* Summon devil */
#define RF6_S_DEMON                 0x02000000      /* Summon Demon */
#define RF6_S_UNDEAD                0x04000000      /* Summon Undead */
#define RF6_S_DRAGON                0x08000000      /* Summon Dragon */
#define RF6_S_HI_UNDEAD             0x10000000      /* Summon Greater Undead */
#define RF6_S_HI_DRAGON             0x20000000      /* Summon Ancient Dragon */
#define RF6_S_FALLEN                0x40000000      /* Summon fallen angel */
#define RF6_S_UNIQUE                0x80000000      /* Summon Unique Monster */

#define RF7_ANNOYED                 0x00000001      /* Annoyed ? */
#define RF7_NO_SPAWN                0x00000002      /* Can only be summoned */
#define RF7_STORM                   0x00000004      /* Afflicted by the Lovers' Storm */
#define RF7_RES_DARK                0x00000008      /* Resist darkness */
#define RF7_IM_DARK                 0x00000010      /* Immunity darkness */
#define RF7_HEAL_DARK               0x00000020      /* Darkness healing */
#define RF7_HURT_DARK               0x00000040      /* Extra Hurt by darkness */
#define RF7_RES_LITE                0x00000080      /* Resist light */
#define RF7_IM_LITE                 0x00000100      /* Immunity to light */
#define RF7_HEAL_LITE               0x00000200      /* Heal by light */
#define RF7_RES_COLD                0x00000400      /* Resist cold*/
#define RF7_HEAL_COLD               0x00000800      /* Heal by cold */
#define RF7_RES_FIRE                0x00001000      /* Resist Fire */
#define RF7_HEAL_FIRE               0x00002000      /* Heal by Fire */
#define RF7_RES_ACID                0x00004000      /* Resists Acid */
#define RF7_RES_ELEC                0x00008000      /* Resist Electricity */
#define RF7_HEAL_ELEC               0x00010000      /* Heal by Electricity */
#define RF7_HEAL_NETH				0x00020000      /* Heal by Nether */
#define RF7_RES_POIS				0x00040000      /* Resist poison */
#define RF7_AQUATIC                 0x00080000      /* Thrives in water */
#define RF7_FLIGHT                  0x00100000      /* Can fly or levitate */
#define RF7_NEUTRAL                 0x00200000      /* Doesnt want to kill player when generated */
#define RF7_REBORN                  0x00400000      /* Doesnt stay dead */
#define RF7_XXX24                   0x00800000      /*  */
#define RF7_XXX25                   0x01000000      /*  */
#define RF7_XXX26                   0x02000000      /*  */
#define RF7_XXX27                   0x04000000      /*  */
#define RF7_XXX28                   0x08000000      /*  */
#define RF7_XXX29                   0x10000000      /*  */
#define RF7_XXX30                   0x20000000      /*  */
#define RF7_XXX31                   0x40000000      /*  */
#define RF7_XXX32                   0x80000000      /*  */


/*
* Hack -- choose "intelligent" spells when desperate
*/

#define RF4_INT_MASK \
	0L

#define RF5_INT_MASK \
	(RF5_HOLD | RF5_SLOW | RF5_CONF | RF5_BLIND | RF5_SCARE)

#define RF6_INT_MASK \
	(RF6_BLINK |  RF6_TPORT | RF6_TELE_LEVEL | RF6_TELE_AWAY | \
	RF6_HEAL | RF6_HASTE | RF6_TRAPS | \
	RF6_S_KIN | RF6_S_REAVER | RF6_S_MONSTER | RF6_S_MONSTERS | \
	RF6_S_ANT | RF6_S_SPIDER | RF6_S_HOUND | RF6_S_HYDRA | \
	RF6_S_DEVIL | RF6_S_DRAGON | RF6_S_UNDEAD | RF6_S_DEMON | \
	RF6_S_HI_DRAGON | RF6_S_HI_UNDEAD | RF6_S_FALLEN | RF6_S_UNIQUE)


/*
* Hack -- "bolt" spells that may hurt fellow monsters
*/
#define RF4_BOLT_MASK \
	(RF4_ARROW_1 | RF4_ARROW_2 | RF4_ARROW_3 | RF4_ARROW_4)

#define RF5_BOLT_MASK \
	(RF5_BO_ACID | RF5_BO_ELEC | RF5_BO_FIRE | RF5_BO_COLD | \
	RF5_BO_POIS | RF5_BO_NETH | RF5_BO_WATE | RF5_BO_MANA | \
	RF5_BO_PLAS | RF5_BO_ICEE | RF5_MISSILE)

#define RF6_BOLT_MASK \
	0L


/* Hack -- summon spells */

#define RF4_SUMMON_MASK \
	0L

#define RF5_SUMMON_MASK \
	0L

#define RF6_SUMMON_MASK \
	(RF6_S_KIN | RF6_S_REAVER | RF6_S_MONSTER | RF6_S_MONSTERS | RF6_S_ANT | \
	RF6_S_SPIDER | RF6_S_HOUND | RF6_S_HYDRA | RF6_S_DEVIL | RF6_S_DEMON | \
	RF6_S_UNDEAD | RF6_S_DRAGON | RF6_S_HI_UNDEAD | RF6_S_HI_DRAGON | \
	RF6_S_FALLEN | RF6_S_UNIQUE)


/*** Macro Definitions ***/


/*
* Hack -- The main "screen"
*/
#define term_screen     (angband_term[0])


/*
* Determine if a given inventory item is "aware"
*/
#define object_aware_p(T) \
	(k_info[(T)->k_idx].aware)

/*
* Determine if a given inventory item is "tried"
*/
#define object_tried_p(T) \
	(k_info[(T)->k_idx].tried)

/*
* Determine if a given inventory item is "known"
* Test One -- Check for special "known" tag
* Test Two -- Check for "Easy Know" + "Aware"
*/
#define object_known_p(T) \
	(((T)->ident & (IDENT_KNOWN)) || \
	(k_info[(T)->k_idx].easy_know && k_info[(T)->k_idx].aware))


/*
 * is regular artefact or randart or sentient
 */
#define artefact_prs(T) \
	( ( (T)->name1||(T)->art_flags1||(T)->art_flags2||(T)->art_flags3 )? TRUE : FALSE)

/*
* Artifacts use the "name1" field
*/
#define artefact_p(T) \
	((T)->name1 ? TRUE : FALSE)

/*
* Ego-Items use the "name2" field
*/
#define ego_item_p(T) \
	((T)->name2 ? TRUE : FALSE)


/*
* Broken items.
*/
#define broken_p(T) \
	((T)->ident & (IDENT_BROKEN))

/*
* Cursed items.
*/
#define cursed_p(T) \
	((T)->ident & (IDENT_CURSED))



/*
* Determines if a map location is fully inside the outer walls
*/
#define in_bounds(Y,X) \
	(((Y) > 0) && ((X) > 0) && ((Y) < cur_hgt-1) && ((X) < cur_wid-1))

/*
* Determines if a map location is on or inside the outer walls
* THIS ONE IS FOR SIGNED, if you update this, update in_bounds2 as well
*/
#define in_bounds2(Y,X) \
	(((Y) >= 0) && ((X) >= 0) && ((Y) < cur_hgt) && ((X) < cur_wid))

/*
 * Determines if a map location is on or inside the outer walls
 * THIS ONE IS FOR UNSIGNED, if you update this, update in_bounds2 as well
 */
#define in_bounds2_unsigned(Y,X) \
(((Y) < cur_hgt) && ((X) < cur_wid))

/*
* Determines if a map location is currently "on screen" -RAK-
* Note that "panel_contains(Y,X)" always implies "in_bounds2(Y,X)".
*/
#define panel_contains(Y,X) \
	(((Y) >= panel_row_min) && ((Y) <= panel_row_max) && \
	((X) >= panel_col_min) && ((X) <= panel_col_max))



/*
* Determine if a "legal" grid is a "floor" grid
*
* Line 1 -- forbid doors, rubble, seams, walls, trees
*
* Note that the terrain features are split by a one bit test
* into those features which block line of sight and those that
* do not, allowing an extremely fast single bit check below.
*/
#define cave_floor_bold(Y,X) \
	(((!(cave[Y][X].feat & 0x20)) && (!(cave[Y][X].feat == FEAT_BUSH))) || (cave[Y][X].feat == FEAT_WATER))

/*
* Determine if a "legal" grid is a "clean" floor grid
*
* Line 1 -- forbid non-floors
* Line 2 -- forbid normal objects
*/
#define cave_clean_bold(Y,X) \
	((cave[Y][X].feat == FEAT_FLOOR) && \
	(!cave[Y][X].o_idx))

/*
* Determine if a "legal" grid is an "empty" floor grid
*
* Line 1 -- forbid doors, rubble, seams, walls
* Line 2 -- forbid normal monsters
* Line 3 -- forbid the player
*/
#define cave_empty_bold(Y,X) \
	(cave_floor_bold(Y,X) && \
	!(cave[Y][X].m_idx) && \
	!(((Y) == py) && ((X) == px)))

/*
* Determine if a "legal" grid is an "naked" floor grid
*
* Line 1 -- forbid non-floors
* Line 2 -- forbid normal objects
* Line 3 -- forbid normal monsters
* Line 4 -- forbid the player
*/
#define cave_naked_bold(Y,X) \
	((cave[Y][X].feat == FEAT_FLOOR) && \
	!(cave[Y][X].o_idx) && \
	!(cave[Y][X].m_idx) && \
	!((Y == py) && (X == px)))


/*
* Determine if a "legal" grid is "permanent"
*
* Line 1 -- perma-walls
* Line 2-3 -- stairs
* Line 4 -- town gate
* Line 5-6 -- shop doors
*/
#define cave_perma_bold(Y,X) \
	((cave[Y][X].feat >= FEAT_PERM_BUILDING) || \
	((cave[Y][X].feat == FEAT_LESS) || \
	(cave[Y][X].feat == FEAT_MORE)) || \
	(cave[Y][X].feat == FEAT_WILD_BORDER) || \
	(cave[Y][X].feat == FEAT_PATH_BORDER) || \
	((cave[Y][X].feat >= FEAT_SHOP_HEAD) && \
	(cave[Y][X].feat <= FEAT_SHOP_TAIL)))


/*
* Grid based version of "cave_floor_bold()"
*/
#define cave_floor_grid(C) \
	((!((C)->feat & 0x20) && (!((C)->feat == FEAT_BUSH))) || ((C)->feat == FEAT_WATER))


/*
* Grid based version of "cave_clean_bold()"
*/
#define cave_clean_grid(C) \
	(((C)->feat == FEAT_FLOOR) && \
	(!(C)->o_idx))

/*
* Grid based version of "cave_empty_bold()"
*/
#define cave_empty_grid(C) \
	(cave_floor_grid(C) && \
	!((C)->m_idx) && \
	!((C) == &cave[py][px]))

/*
* Grid based version of "cave_empty_bold()"
*/
#define cave_naked_grid(C) \
	(((C)->feat == FEAT_FLOOR) && \
	!((C)->o_idx) && \
	!((C)->m_idx) && \
	!((C) == &cave[py][px]))


/*
* Grid based version of "cave_perma_bold()"
*/
#define cave_perma_grid(C) \
	(((C)->feat >= FEAT_PERM_BUILDING) || \
	(((C)->feat == FEAT_LESS) || \
	((C)->feat == FEAT_MORE)) || \
	((C)->feat == FEAT_BUSH) || \
	(((C)->feat >= FEAT_SHOP_HEAD) && \
	((C)->feat <= FEAT_SHOP_TAIL)))



/*
* Determine if a "legal" grid is within "los" of the player
*
* Note the use of comparison to zero to force a "boolean" result
*/
#define player_has_los_bold(Y,X) \
	((cave[Y][X].info & (CAVE_VIEW)) != 0)





/*** Color constants ***/


/*
* Angband "attributes" (with symbols, and base (R,G,B) codes)
*
* The "(R,G,B)" codes are given in "fourths" of the "maximal" value,
* and should "gamma corrected" on most (non-Macintosh) machines.
*/
#define TERM_DARK               0       /* 'd' */       /* 0,0,0 */
#define TERM_WHITE              1       /* 'w' */       /* 4,4,4 */
#define TERM_SLATE              2       /* 's' */       /* 2,2,2 */
#define TERM_ORANGE             3       /* 'o' */       /* 4,2,0 */
#define TERM_RED                4       /* 'r' */       /* 3,0,0 */
#define TERM_GREEN              5       /* 'g' */       /* 0,2,1 */
#define TERM_BLUE               6       /* 'b' */       /* 0,0,4 */
#define TERM_UMBER              7       /* 'u' */       /* 2,1,0 */
#define TERM_L_DARK             8       /* 'D' */       /* 1,1,1 */
#define TERM_L_WHITE            9       /* 'W' */       /* 3,3,3 */
#define TERM_VIOLET             10      /* 'v' */       /* 4,0,4 */
#define TERM_YELLOW             11      /* 'y' */       /* 4,4,0 */
#define TERM_L_RED              12      /* 'R' */       /* 4,0,0 */
#define TERM_L_GREEN            13      /* 'G' */       /* 0,4,0 */
#define TERM_L_BLUE             14      /* 'B' */       /* 0,4,4 */
#define TERM_L_UMBER            15      /* 'U' */       /* 3,2,1 */


/*** Sound constants ***/


/*
* Mega-Hack -- some primitive sound support (see "main-win.c")
*
* Some "sound" constants for "Term_xtra(TERM_XTRA_SOUND, val)"
*/
#define SOUND_HIT           1
#define SOUND_MISS          2
#define SOUND_FLEE          3
#define SOUND_DROP          4
#define SOUND_KILL          5
#define SOUND_LEVEL         6
#define SOUND_DEATH         7
#define SOUND_STUDY     8
#define SOUND_TELEPORT  9
#define SOUND_SHOOT     10
#define SOUND_QUAFF     11
#define SOUND_ZAP       12
#define SOUND_WALK      13
#define SOUND_TPOTHER   14
#define SOUND_HITWALL   15
#define SOUND_EAT       16
#define SOUND_STORE1    17
#define SOUND_STORE2    18
#define SOUND_STORE3    19
#define SOUND_STORE4    20
#define SOUND_DIG       21
#define SOUND_OPENDOOR  22
#define SOUND_SHUTDOOR  23
#define SOUND_TPLEVEL   24
#define SOUND_SCROLL	25
#define SOUND_BUY	26
#define SOUND_SELL	27
#define SOUND_WARN 28

/*
* Mega-Hack -- maximum known sounds
*/
#define SOUND_MAX 29

#define MSG_MAX   153


/*** Hack ***/


/*
* Hack -- attempt to reduce various values
*/
#ifdef ANGBAND_LITE
# undef MACRO_MAX
# define MACRO_MAX      128
# undef QUARK_MAX
# define QUARK_MAX      128
# undef MESSAGE_MAX
# define MESSAGE_MAX    128
# undef MESSAGE_BUF
# define MESSAGE_BUF    4096
#endif

/*
 * Available graphic modes
 */
#define GRAPHICS_NONE           0
#define GRAPHICS_ORIGINAL       1
#define GRAPHICS_ADAM_BOLT      2
#define GRAPHICS_DAVID_GERVAIS  3
#define GRAPHICS_PSEUDO         4

/*
 * Squelch modes
 */
#define SQUELCH_NO				0
#define SQUELCH_GOOD			1
#define SQUELCH_EXCELLENT		2
#define SQUELCH_GREAT			3
#define SQUELCH_ALL_ID			4
#define SQUELCH_TOWN_BOOKS		5
#define SQUELCH_OPENED			6
#define SQUELCH_ALL				7
#define SQUELCH_ARTIFACT		8

/*
 * Squelch modes in bit flag mode for selection 
 */
#define CH_SQUELCH_NO				0
#define CH_SQUELCH_GOOD				1
#define CH_SQUELCH_EXCELLENT		2
#define CH_SQUELCH_GREAT			4
#define CH_SQUELCH_ALL_ID			8
#define CH_SQUELCH_TOWN_BOOKS		16
#define CH_SQUELCH_OPENED			32
#define CH_SQUELCH_ALL				64
#define CH_SQUELCH_ARTIFACT			128

/*
 * High Level(HL) Categories for which squelch modes can be chosen
 * Major head aches will be achieved if you dont update SQ_HL_COUNT after
 * adding more categories
 */
#define SQ_HL_WEAPONS	0
#define SQ_HL_ARMOURS	1
#define SQ_HL_AMMO		2
#define SQ_HL_JEWELRY	3
#define SQ_HL_LIGHTS	4
#define SQ_HL_WANDS		5
#define SQ_HL_STAVES	6
#define SQ_HL_RODS		7
#define SQ_HL_SCROLLS	8
#define SQ_HL_BOOKS		9
#define SQ_HL_MISC		10
#define SQ_HL_CHESTS	11
#define SQ_HL_COUNT		12		
#define SQ_HL_OTHERS	12	

/*
 * What price makes it great ?
 */
#define GREAT_PRICE				1000
#define SQUELCH_PRICE_START		5000
#define SQUELCH_PRICE_INC		5000
#define SQUELCH_PRICE_MAX		50000

/*
 * Scripting vars
 */

#define UNKNOWN   0
#define DELIMITER 1
#define VARIABLE  2
#define NUMBER    3

#define WORST_CASE 0
#define BEST_CASE  1
#define ROLL       2

#define SCRIPT_MAX_LENGTH 80

/*
 * Timed effects vars
 */

#define TIMED_FAST			0 
#define TIMED_SLOW			1
#define TIMED_BLIND			2
#define TIMED_PARALYZED	    3
#define TIMED_CONFUSED	    4
#define TIMED_AFRAID		5
#define TIMED_IMAGE			6
#define TIMED_POISONED	    7
#define TIMED_CUT			8
#define TIMED_STUN			9
#define TIMED_PROTEVIL	    10
#define TIMED_INVULN		11
#define TIMED_HERO			12
#define TIMED_SHERO			13
#define TIMED_SHIELD		14
#define TIMED_BLESSED	    15
#define TIMED_TIM_INVIS	    16
#define TIMED_TIM_INFRA	    17
#define TIMED_MAGIC_SHELL   18
#define TIMED_OPPOSE_ACID	19
#define TIMED_OPPOSE_ELEC	20
#define TIMED_OPPOSE_FIRE	21
#define TIMED_OPPOSE_COLD	22
#define TIMED_OPPOSE_POIS	23
#define TIMED_ESP           24
#define TIMED_WRAITH_FORM   25
#define TIMED_OPPOSE_CONF   26
#define TIMED_OPPOSE_FEAR   27
#define TIMED_OPPOSE_BLIND  28

#define TIMED_COUNT         29

/*
 * Adjustment 2D Matrix indexes
 */
#define ADJ_SPELLS   0 
#define ADJ_MANA     1 
#define ADJ_FAILURE  2 
#define ADJ_INTWIS   3 
#define ADJ_PRICE    4 
#define ADJ_DEVICE   5 
#define ADJ_RESIST   6 
#define ADJ_DEX_TRAP 7 
#define ADJ_INT_TRAP 8 
#define ADJ_AC       9
#define ADJ_DAM      10
#define ADJ_DEX_HIT  11
#define ADJ_STR_HIT  12
#define ADJ_WEIGHT   13
#define ADJ_SIZE     14
#define ADJ_DIG      15
#define ADJ_STR_BLOW 16
#define ADJ_DEX_BLOW 17
#define ADJ_DODGE    18
#define ADJ_REGEN    19
#define ADJ_HP       20

/*
 * Bit flags for the "get_item" function
 */
#define USE_EQUIP		0x01	/* Allow equip items */
#define USE_INVEN		0x02	/* Allow inven items */
#define USE_FLOOR		0x04	/* Allow floor items */


/*
* Return the "attr" for a given item.
* Allow user redefinition of "aware" items.
* Default to the "base" attr for unaware items
*/
#define object_attr(T) \
	((k_info[(T)->k_idx].aware) ? \
	(k_info[(T)->k_idx].x_attr) : \
	(k_info[(T)->k_idx].d_attr))

/*
* Return the "char" for a given item.
* Allow user redefinition of "aware" items.
* Default to the "base" char for unaware items
*/
#define object_char(T) \
	((k_info[(T)->k_idx].aware) ? \
	(k_info[(T)->k_idx].x_char) : \
	(k_info[(T)->k_idx].d_char))

/*
 * 2 flags for birth items, indicating whether the item should be worn or carried
 */
#define WORN					0
#define CARRIED					1

/*
 * Given an array, determine how many elements are in the array
 */
#define N_ELEMENTS(a) (sizeof (a) / sizeof ((a)[0]))

